This course is no longer maintained and may be out-of-date. While it remains available for reference, its content may not reflect the latest updates, best practices, or supported features.
Setup Auth in Remix
Create ./app/utils/sessions.server.ts
import { createCookieSessionStorage } from "remix";// Learn more about cookies at MDN https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies// With Firebase hosting your cookie must be named __session https://firebase.google.com/docs/hosting/manage-cache#using_cookiesconst { getSession, commitSession, destroySession } =createCookieSessionStorage({cookie: {name: "__session",secrets: [process.env.COOKIE_SECRET!],sameSite: "lax",httpOnly: true,secure: true,path: "/",// Set session expiration to 5 daysmaxAge: 60 * 60 * 24 * 5,},});export { getSession, commitSession, destroySession };
We have .server in the file name so the compiler knows we are only using this module server side
Did you find this page helpful?
Start with GraphQL on Hasura for Free
Build apps and APIs 10x faster
Built-in authorization and caching
8x more performant than hand-rolled APIs

