UNPKG

@happykit/auth-email

Version:

- A `useAuth` hook which returns the current user - An optional `getServerSideAuth` for server-side rendering - HappyAuth is tiny - it adds only 4.6 kB to the first load JS - it adds less than 0.04 kB if you're transitioning from another page - Extremely

28 lines (25 loc) 839 B
import { createGetServerSideAuth, ServerConfig, sendConfirmAccountMailToConsole, sendForgotPasswordMailToConsole, createFaunaEmailDriver, } from "@happykit/auth-email/api" import { TokenData } from "." import { faunaClient } from "fauna-client" export const serverConfig: ServerConfig = { tokenSecret: process.env.HAPPYAUTH_TOKEN_SECRET!, cookieName: "happyauth", secure: process.env.NODE_ENV === "production", identityProviders: {}, triggers: { sendConfirmAccountMail: sendConfirmAccountMailToConsole, sendForgotPasswordMail: sendForgotPasswordMailToConsole, }, driver: createFaunaEmailDriver(faunaClient), } /* you can probably leave these as they are */ export type AuthState = ReturnType<typeof getServerSideAuth> export const getServerSideAuth = createGetServerSideAuth<TokenData>( serverConfig, )