Socket
Socket
Sign inDemoInstall

next-protected-auth

Package Overview
Dependencies
3
Maintainers
1
Versions
324
Alerts
File Explorer

Advanced tools

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


Version published
Weekly downloads
513
increased by0.59%
Maintainers
1
Created
Weekly downloads
ย 

Readme

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

Last updated on 02 May 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