Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

next-protected-auth

Package Overview
Dependencies
Maintainers
0
Versions
413
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-protected-auth

[![Maintainability](https://api.codeclimate.com/v1/badges/1c3d4f9f17d9514df0ec/maintainability)](https://codeclimate.com/github/qlaffont/next-protected-auth/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/1c3d4f9f17d9514df0ec/test

  • 2.0.391
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
113
decreased by-80.38%
Maintainers
0
Weekly downloads
 
Created
Source

Maintainability Test Coverage npm npm Snyk Vulnerabilities for npm package NPM

Next Protected Auth

Add protected routes to Next.js. Old Owner: @flexper

Usage

See example folder

API

NextAuthProtectedLogin

Options

Field NameTypeDescription
callbackVoidFunction / AsyncVoidFunctionSpecify a callback after login (generally redirect to oauth portal)
authCallbackURLstringSpecify auth callback url in case of accessToken already exist

Return: React Component

NextAuthProtectedLogout

Options

Field NameTypeDescription
preCallbackVoidFunction / AsyncVoidFunctionSpecify a callback before logout (generally send to api that user want to logout)
callbackVoidFunction / AsyncVoidFunctionSpecify a callback after logout (generally redirect to home)

Return: React Component

NextAuthProtectedCallback

Options

Field NameTypeDescription
callbackVoidFunction / AsyncVoidFunctionSpecify a callback after auth callback (generally redirect to protected routes)

Return: React Component

useNextAuthProtectedHandler

Options

Field NameTypeDescription
publicURLsstring[]List of public URLs
loginURLstringEndpoint for login (ex: /auth/login)
authCallbackURLstringEndpoint for auth callback (ex: /auth)
renewTokenFct(oldAccessToken?: string) => stringFunction who will run to renew token (ex: refresh token)
verifyTokenFct(accessToken?: string) => stringFunction who test accessToken validity (ex: verify JWT token expiration)
allowNotFoundboolean?Allow to consult Not found pages in public

Return: Hook who need to be use to pages/_app.tsx

useNextAuthProtected

Return: {isConnected: boolean; setIsConnected: Dispatch} // User is connected

getAndSaveAccessToken

Options

Field NameTypeDescription
renewTokenFct(oldAccessToken?: string) => string OR PromiseFunction who will run to renew token (ex: refresh token) to
accessTokenstringaccess token to save

Return: boolean (Token is saved)

getAccessToken

Return: string (Return access token)

removeAccessToken

Return: void

Maintain

This package use TSdx. Please check documentation to update this package.

FAQs

Package last updated on 29 Nov 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc