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.
Create logout component
Following the Remix tutorial example we build a logout action in ./app/routes/logout.tsx
. We POST to it using a Form in root.tsx
and include the CSRF token.
import { ActionFunction, LoaderFunction, redirect } from "remix";import { destroySession } from "~/utils/sessions.server";import { admin } from "~/utils/firebase.server";import { getSessionData } from "~/utils/auth.server";export const loader: LoaderFunction = async ({ request }) => {return redirect("/");};export const action: ActionFunction = async ({ request }) => {const { session, idToken } = await getSessionData(request, true);const jwtToken = await admin.auth().verifySessionCookie(idToken!);await admin.auth().revokeRefreshTokens(jwtToken.sub);return redirect("/", {headers: {"Set-Cookie": await destroySession(session),},});};
You now should be able to run the app npm run dev
and test out the login/logout.
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

