🚀Announcing Flightcontrol - Easily Deploy Blitz.js and Next.js to AWS 🚀
Back to Documentation Menu



Jump to a Topic

Install @blitzjs/auth plugin with:

npm i @blitzjs/auth # yarn add @blitzjs/auth # pnpm add @blitzjs/auth

Client setup

Add the following to your blitz-client.ts file:

import { AuthClientPlugin } from "@blitzjs/auth"
import { setupBlitzClient } from "@blitzjs/next"

export const authConfig = {
  cookiePrefix: "testapp",

const { withBlitz } = setupBlitzClient({
  plugins: [AuthClientPlugin(authConfig)],

export { withBlitz }

Server setup

Then, add the following to the blitz-server.ts file:

import { setupBlitzServer } from "@blitzjs/next"
import {
} from "@blitzjs/auth"
import { db } from "db"
import { authConfig } from "./blitz-client"

const { gSSP, gSP, api } = setupBlitzServer({
  plugins: [
      storage: PrismaStorage(db),
      isAuthorized: simpleRolesIsAuthorized,

export { gSSP, gSP, api }

Production Deployment Requirements

In production, you must provide the SESSION_SECRET_KEY environment variable with at least 32 characters. This is your private key for signing JWT tokens.

On macOS and Linux, you can generate it by running openssl rand -hex 16 in your terminal.

Idea for improving this page? Edit it on GitHub.