@blitzjs/auth
TypeScript icon, indicating that this package has built-in type declarations

2.0.10 • Public • Published

Blitz.js


Blitz Auth - Framework Agnostic Authentication


Quick Start

Install Blitz Auth

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

You can alternatively use npx

Framework Support

Currently Blitz Auth usage is only documented with Next.js. We are working on adding additional support for other frameworks.

Setup Blitz Auth in Next.js

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 {AuthServerPlugin, PrismaStorage, simpleRolesIsAuthorized} from "@blitzjs/auth"
import {db} from "db"
import {authConfig} from "./blitz-client"

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

export {gSSP, gSP, api}

Readme

Keywords

none

Package Sidebar

Install

npm i @blitzjs/auth

Homepage

blitzjs.com/

Weekly Downloads

4,177

Version

2.0.10

License

MIT

Unpacked Size

213 kB

Total Files

27

Last publish

Collaborators

  • siddhsuresh
  • dillonraphael
  • mabadir
  • flybayer
  • skn0tt