next-auth-hook
Version:
A simple React hook for NextAuth.js with Next.js App Router
26 lines (25 loc) • 1.1 kB
TypeScript
/// <reference types="react" />
import { QueryClient } from '@tanstack/react-query';
import type { User } from 'next-auth';
import type { SignOutParams, SignInOptions, SignInResponse, LiteralUnion } from 'next-auth/react';
import type { Session } from 'next-auth';
import type { BuiltInProviderType } from 'next-auth/providers/index';
type AuthContextType = {
isAuthenticated: boolean;
user: User | null;
email: string | null;
loading?: boolean;
signOut: (a: SignOutParams) => Promise<void>;
signIn: (provider: LiteralUnion<BuiltInProviderType>, options: SignInOptions) => Promise<SignInResponse | void>;
session?: Session | null;
};
declare const AuthContext: import("react").Context<AuthContextType>;
declare const useSession: () => AuthContextType;
type AuthProviderProps = {
children?: React.ReactNode;
client: QueryClient;
};
declare const AuthProvider: ({ children, client }: AuthProviderProps) => import("react/jsx-runtime").JSX.Element;
export default AuthProvider;
export { AuthContext, useSession };
export type { AuthContextType, AuthProviderProps };