{"id":15573057,"url":"https://github.com/qlaffont/next-protected-auth","last_synced_at":"2025-07-27T20:07:00.133Z","repository":{"id":59862666,"uuid":"538966497","full_name":"qlaffont/next-protected-auth","owner":"qlaffont","description":"Next.JS Protected auth plugin","archived":false,"fork":false,"pushed_at":"2025-04-23T20:15:24.000Z","size":1391,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-24T02:14:40.139Z","etag":null,"topics":["authentication","nextjs","routes","routing","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/next-protected-auth","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qlaffont.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-09-20T12:01:28.000Z","updated_at":"2025-04-23T20:15:05.000Z","dependencies_parsed_at":"2023-08-28T13:46:06.531Z","dependency_job_id":"bca7ecdb-449a-4172-b0fb-7efdd4c6bf61","html_url":"https://github.com/qlaffont/next-protected-auth","commit_stats":{"total_commits":830,"total_committers":5,"mean_commits":166.0,"dds":0.4891566265060241,"last_synced_commit":"f17a132d958cfb48c3fc5f25a00ca5c2bc49d61d"},"previous_names":["qlaffont/next-protected-auth","flexper/next-protected-auth"],"tags_count":441,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qlaffont%2Fnext-protected-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qlaffont%2Fnext-protected-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qlaffont%2Fnext-protected-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qlaffont%2Fnext-protected-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qlaffont","download_url":"https://codeload.github.com/qlaffont/next-protected-auth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250546097,"owners_count":21448263,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authentication","nextjs","routes","routing","typescript"],"created_at":"2024-10-02T18:10:18.901Z","updated_at":"2025-04-24T02:14:59.897Z","avatar_url":"https://github.com/qlaffont.png","language":"TypeScript","readme":"[![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_coverage)](https://codeclimate.com/github/qlaffont/next-protected-auth/test_coverage) ![npm](https://img.shields.io/npm/v/next-protected-auth) ![npm](https://img.shields.io/npm/dm/next-protected-auth) ![Snyk Vulnerabilities for npm package](https://img.shields.io/snyk/vulnerabilities/npm/next-protected-auth) ![NPM](https://img.shields.io/npm/l/next-protected-auth)\n\n# Next Protected Auth\n\nAdd protected routes to Next.js. Old Owner: [@flexper](https://github.com/flexper)\n\n## Usage\n\nSee example folder\n\n\n## API\n\n### NextAuthProtectedLogin\n\n**Options**\n\n| Field Name      | Type                             | Description                                                         |\n| --------------- | -------------------------------- | ------------------------------------------------------------------- |\n| callback        | VoidFunction / AsyncVoidFunction | Specify a callback after login (generally redirect to oauth portal) |\n| authCallbackURL | string                           | Specify auth callback url in case of accessToken already exist      |\n\nReturn: React Component\n\n### NextAuthProtectedLogout\n\n**Options**\n\n| Field Name  | Type                             | Description                                                                       |\n| ----------- | -------------------------------- | --------------------------------------------------------------------------------- |\n| preCallback | VoidFunction / AsyncVoidFunction | Specify a callback before logout (generally send to api that user want to logout) |\n| callback    | VoidFunction / AsyncVoidFunction | Specify a callback after logout (generally redirect to home)                      |\n\nReturn: React Component\n\n### NextAuthProtectedCallback\n\n**Options**\n\n| Field Name | Type                             | Description                                                                     |\n| ---------- | -------------------------------- | ------------------------------------------------------------------------------- |\n| callback   | VoidFunction / AsyncVoidFunction | Specify a callback after auth callback (generally redirect to protected routes) |\n\n\nReturn: React Component\n\n### useNextAuthProtectedHandler\n\n**Options**\n\n| Field Name      | Type                                | Description                                                              |\n| --------------- | ----------------------------------- | ------------------------------------------------------------------------ |\n| publicURLs      | string[]                            | List of public URLs                                                      |\n| loginURL        | string                              | Endpoint for login (ex: /auth/login)                                     |\n| authCallbackURL | string                              | Endpoint for auth callback (ex: /auth)                                   |\n| renewTokenFct   | (oldAccessToken?: string) =\u003e string | Function who will run to renew token (ex: refresh token)                 |\n| verifyTokenFct  | (accessToken?: string) =\u003e string    | Function who test accessToken validity (ex: verify JWT token expiration) |\n| allowNotFound   | boolean?                            | Allow to consult Not found pages in public                               |\n\nReturn: Hook who need to be use to pages/_app.tsx\n\n### useNextAuthProtected\n\nReturn: {isConnected: boolean; setIsConnected: Dispatch\u003cboolean\u003e} // User is connected\n\n### getAndSaveAccessToken\n\n**Options**\n\n| Field Name    | Type                                                   | Description                                                  |\n| ------------- | ------------------------------------------------------ | ------------------------------------------------------------ |\n| renewTokenFct | (oldAccessToken?: string) =\u003e string OR Promise\u003cstring\u003e | Function who will run to renew token (ex: refresh token)  to |\n| accessToken   | string                                                 | access token to save                                         |\n\nReturn: boolean (Token is saved)\n\n### getAccessToken\n\nReturn: string  (Return access token)\n\n### removeAccessToken\n\nReturn: void\n\n## Maintain\n\nThis package use [TSdx](https://github.com/jaredpalmer/tsdx). Please check documentation to update this package.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqlaffont%2Fnext-protected-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqlaffont%2Fnext-protected-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqlaffont%2Fnext-protected-auth/lists"}