Socket
Socket
Sign inDemoInstall

@blitzjs/auth

Package Overview
Dependencies
21
Maintainers
5
Versions
150
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @blitzjs/auth

[![Blitz.js](https://raw.githubusercontent.com/blitz-js/art/master/github-cover-photo.png)](https://blitzjs.com)


Version published
Weekly downloads
3.8K
increased by7.61%
Maintainers
5
Created
Weekly downloads
 

Readme

Source

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}

FAQs

Last updated on 17 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc