Skip to content

Latest commit

 

History

History
30 lines (21 loc) · 889 Bytes

File metadata and controls

30 lines (21 loc) · 889 Bytes

AuthContext

The library does not come with a client-side code or any built-in authentication context feature. It is up to developer how they will implement user data flow throughout application.

See below for an example AuthContext

Example AuthContext

The following is an example implementation of custom AuthContext using React's createContext.

import {createContext, useContext} from 'react';
import {UserInfo} from 'firebase/auth';
import {Claims} from 'next-firebase-auth-edge/lib/auth/claims';

export interface User extends UserInfo {
  emailVerified: boolean;
  customClaims: Claims;
}

export interface AuthContextValue {
  user: User | null;
}

export const AuthContext = createContext<AuthContextValue>({
  user: null
});

export const useAuth = () => useContext(AuthContext);