{"_id":"@alphanovatech/nextjs-auth0","name":"@alphanovatech/nextjs-auth0","dist-tags":{"patch":"4.0.1-alphanova.1","latest":"4.0.1-alphanova.1"},"versions":{"4.0.1-alphanova.1":{"name":"@alphanovatech/nextjs-auth0","version":"4.0.1-alphanova.1","description":"Auth0 Next.js SDK","scripts":{"build":"tsc","build:watch":"tsc -w","test:unit":"vitest","test:coverage":"vitest run --coverage","test:e2e":"playwright test","prepack":"pnpm run build","install:examples":"pnpm install --filter ./examples/with-next-intl --shamefully-hoist && pnpm install --filter ./examples/with-shadcn --shamefully-hoist","docs":"typedoc","lint":"tsc --noEmit && eslint --fix ./src"},"repository":{"type":"git","url":"git+https://github.com/auth0/nextjs-auth0.git"},"keywords":["auth0","next.js","react","oidc","authentication","vercel"],"author":{"name":"Auth0","url":"https://auth0.com"},"license":"MIT","bugs":{"url":"https://github.com/auth0/nextjs-auth0/issues"},"homepage":"https://github.com/auth0/nextjs-auth0#readme","devDependencies":{"@eslint/js":"^9.20.0","@ianvs/prettier-plugin-sort-imports":"^4.3.1","@playwright/test":"^1.48.2","@stylistic/eslint-plugin-ts":"^3.1.0","@types/node":"^22.8.6","@types/react":"*","@types/react-dom":"*","@vitest/coverage-v8":"2.1.4","eslint":"^9.20.0","eslint-config-prettier":"^10.0.1","eslint-plugin-prettier":"^5.2.3","eslint-plugin-react":"^7.37.4","globals":"^15.14.0","next":"15.0.2","prettier":"^3.3.3","typedoc":"^0.27.7","typescript":"^5.6.3","typescript-eslint":"^8.23.0","vite":"^5.4.11","vitest":"^2.1.4"},"peerDependencies":{"next":"^14.0.0 || ^15.0.0","react":"^18.0.0 || ^19.0.0 || ^19.0.0-0","react-dom":"^18.0.0 || ^19.0.0 || ^19.0.0-0"},"exports":{".":{"import":"./dist/client/index.js"},"./server":{"import":"./dist/server/index.js"},"./errors":{"import":"./dist/errors/index.js"},"./types":{"import":"./dist/types/index.d.ts"},"./testing":{"import":"./dist/testing/index.js"}},"dependencies":{"@edge-runtime/cookies":"^5.0.1","@panva/hkdf":"^1.2.1","jose":"^5.9.6","oauth4webapi":"^3.1.2","swr":"^2.2.5"},"publishConfig":{"access":"public"},"typesVersions":{"*":{"testing":["./dist/testing/index.d.ts"],"types":["./dist/types/index.d.ts"],"server":["./dist/server/index.d.ts"],"errors":["./dist/errors/index.d.ts"],"*":["./dist/client/*","./dist/client/index.d.ts"]}},"_id":"@alphanovatech/nextjs-auth0@4.0.1-alphanova.1","gitHead":"a00875c736b10839ab373e022ab465788c743ae5","_nodeVersion":"23.1.0","_npmVersion":"11.1.0","dist":{"integrity":"sha512-aL4q9bYN4ud0HYmJa6RKBok/Ah4C+MuFE82w4j1e+2CqAx6tTLwkiaIJXbbnJlVMuo28dgLq2VhGpWDoFke/gw==","shasum":"392da852e4ddd141b2b2d9319208a177e27553fb","tarball":"https://registry.npmjs.org/@alphanovatech/nextjs-auth0/-/nextjs-auth0-4.0.1-alphanova.1.tgz","fileCount":58,"unpackedSize":352496,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIBI9uq2yKUl4ykGX6Y3eBbwaOKNDWtLw0yJ+ENDInlDiAiAw1VX4oaayasYA33vgbx72rZf5mQYUsJFIyHD+veR7zg=="}]},"_npmUser":{"name":"lexalexa","email":"git@alexeyshurygin.com"},"directories":{},"maintainers":[{"name":"lexalexa","email":"git@alexeyshurygin.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/nextjs-auth0_4.0.1-alphanova.1_1739560128211_0.8149780619577922"},"_hasShrinkwrap":false}},"time":{"created":"2025-02-14T19:08:48.128Z","4.0.1-alphanova.1":"2025-02-14T19:08:48.456Z","modified":"2025-02-14T19:08:48.749Z"},"maintainers":[{"name":"lexalexa","email":"git@alexeyshurygin.com"}],"description":"Auth0 Next.js SDK","homepage":"https://github.com/auth0/nextjs-auth0#readme","keywords":["auth0","next.js","react","oidc","authentication","vercel"],"repository":{"type":"git","url":"git+https://github.com/auth0/nextjs-auth0.git"},"author":{"name":"Auth0","url":"https://auth0.com"},"bugs":{"url":"https://github.com/auth0/nextjs-auth0/issues"},"license":"MIT","readme":"![nextjs-auth0](https://cdn.auth0.com/website/sdks/banners/nextjs-auth0-banner.png)\n\nThe Auth0 Next.js SDK is a library for implementing user authentication in Next.js applications.\n\n![Release](https://img.shields.io/npm/v/@auth0/nextjs-auth0)\n![Downloads](https://img.shields.io/npm/dw/@auth0/nextjs-auth0)\n[![License](https://img.shields.io/:license-mit-blue.svg?style=flat)](https://opensource.org/licenses/MIT)\n\n📚 [Documentation](#documentation) - 🚀 [Getting Started](#getting-started) - 💻 [API Reference](https://auth0.github.io/nextjs-auth0/) - 💬 [Feedback](#feedback)\n\n## Documentation\n\n- [QuickStart](https://auth0.com/docs/quickstart/webapp/nextjs)- our guide for adding Auth0 to your Next.js app.\n- [Examples](https://github.com/auth0/nextjs-auth0/blob/main/EXAMPLES.md) - lots of examples for your different use cases.\n- [Security](https://github.com/auth0/nextjs-auth0/blob/main/SECURITY.md) - Some important security notices that you should check.\n- [Docs Site](https://auth0.com/docs) - explore our docs site and learn more about Auth0.\n\n## Getting Started\n\n### 1. Install the SDK\n\n```shell\nnpm i @auth0/nextjs-auth0\n```\n\nThis library requires Node.js 20 LTS and newer LTS versions.\n\n### 2. Add the environment variables\n\nAdd the following environment variables to your `.env.local` file:\n\n```\nAUTH0_DOMAIN=\nAUTH0_CLIENT_ID=\nAUTH0_CLIENT_SECRET=\nAUTH0_SECRET=\nAPP_BASE_URL=\n```\n\nThe `AUTH0_DOMAIN`, `AUTH0_CLIENT_ID`, and `AUTH0_CLIENT_SECRET` can be obtained from the [Auth0 Dashboard](https://manage.auth0.com) once you've created an application. **This application must be a `Regular Web Application`**.\n\nThe `AUTH0_SECRET` is the key used to encrypt the session and transaction cookies. You can generate a secret using `openssl`:\n\n```shell\nopenssl rand -hex 32\n```\n\nThe `APP_BASE_URL` is the URL that your application is running on. When developing locally, this is most commonly `http://localhost:3000`.\n\n> [!IMPORTANT]  \n> You will need to register the follwing URLs in your Auth0 Application via the [Auth0 Dashboard](https://manage.auth0.com):\n>\n> - Add `http://localhost:3000/auth/callback` to the list of **Allowed Callback URLs**\n> - Add `http://localhost:3000` to the list of **Allowed Logout URLs**\n\n### 3. Create the Auth0 SDK client\n\nCreate an instance of the Auth0 client. This instance will be imported and used in anywhere we need access to the authentication methods on the server.\n\nAdd the following contents to a file named `lib/auth0.ts`:\n\n```ts\nimport { Auth0Client } from \"@auth0/nextjs-auth0/server\"\n\nexport const auth0 = new Auth0Client()\n```\n\n### 4. Add the authentication middleware\n\nCreate a `middleware.ts` file in the root of your project's directory:\n\n```ts\nimport type { NextRequest } from \"next/server\"\n\nimport { auth0 } from \"./lib/auth0\"\n\nexport async function middleware(request: NextRequest) {\n  return await auth0.middleware(request)\n}\n\nexport const config = {\n  matcher: [\n    /*\n     * Match all request paths except for the ones starting with:\n     * - _next/static (static files)\n     * - _next/image (image optimization files)\n     * - favicon.ico, sitemap.xml, robots.txt (metadata files)\n     */\n    \"/((?!_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)\",\n  ],\n}\n```\n\n> [!NOTE]  \n> If you're using a `src/` directory, the `middleware.ts` file must be created inside the `src/` directory.\n\nYou can now begin to authenticate your users by redirecting them to your application's `/auth/login` route:\n\n```tsx\nimport { auth0 } from \"@/lib/auth0\"\n\nexport default async function Home() {\n  const session = await auth0.getSession()\n\n  if (!session) {\n    return (\n      <main>\n        <a href=\"/auth/login?screen_hint=signup\">Sign up</a>\n        <a href=\"/auth/login\">Log in</a>\n      </main>\n    )\n  }\n\n  return (\n    <main>\n      <h1>Welcome, {session.user.name}!</h1>\n    </main>\n  )\n}\n```\n\n> [!IMPORTANT]  \n> You must use `<a>` tags instead of the `<Link>` component to ensure that the routing is not done client-side as that may result in some unexpected behavior.\n\n## Customizing the client\n\nYou can customize the client by using the options below:\n\n| Option                      | Type                      | Description                                                                                                                                                                                                                            |\n| --------------------------- | ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| domain                      | `string`                  | The Auth0 domain for the tenant (e.g.: `example.us.auth0.com` or `https://example.us.auth0.com`). If it's not specified, it will be loaded from the `AUTH0_DOMAIN` environment variable.                                               |\n| clientId                    | `string`                  | The Auth0 client ID. If it's not specified, it will be loaded from the `AUTH0_CLIENT_ID` environment variable.                                                                                                                         |\n| clientSecret                | `string`                  | The Auth0 client secret. If it's not specified, it will be loaded from the `AUTH0_CLIENT_SECRET` environment variable.                                                                                                                 |\n| authorizationParameters     | `AuthorizationParameters` | The authorization parameters to pass to the `/authorize` endpoint. See [Passing authorization parameters](#passing-authorization-parameters) for more details.                                                                         |\n| clientAssertionSigningKey   | `string` or `CryptoKey`   | Private key for use with `private_key_jwt` clients. This can also be specified via the `AUTH0_CLIENT_ASSERTION_SIGNING_KEY` environment variable.                                                                                      |\n| clientAssertionSigningAlg   | `string`                  | The algorithm used to sign the client assertion JWT. This can also be provided via the `AUTH0_CLIENT_ASSERTION_SIGNING_ALG` environment variable.                                                                                      |\n| appBaseUrl                  | `string`                  | The URL of your application (e.g.: `http://localhost:3000`). If it's not specified, it will be loaded from the `APP_BASE_URL` environment variable.                                                                                    |\n| secret                      | `string`                  | A 32-byte, hex-encoded secret used for encrypting cookies. If it's not specified, it will be loaded from the `AUTH0_SECRET` environment variable.                                                                                      |\n| signInReturnToPath          | `string`                  | The path to redirect the user to after successfully authenticating. Defaults to `/`.                                                                                                                                                   |\n| session                     | `SessionConfiguration`    | Configure the session timeouts and whether to use rolling sessions or not. See [Session configuration](#session-configuration) for additional details.                                                                                 |\n| beforeSessionSaved          | `BeforeSessionSavedHook`  | A method to manipulate the session before persisting it. See [beforeSessionSaved](#beforesessionsaved) for additional details.                                                                                                         |\n| onCallback                  | `OnCallbackHook`          | A method to handle errors or manage redirects after attempting to authenticate. See [onCallback](#oncallback) for additional details.                                                                                                  |\n| sessionStore                | `SessionStore`            | A custom session store implementation used to persist sessions to a data store. See [Database sessions](#database-sessions) for additional details.                                                                                    |\n| pushedAuthorizationRequests | `boolean`                 | Configure the SDK to use the Pushed Authorization Requests (PAR) protocol when communicating with the authorization server.                                                                                                            |\n| routes                      | `Routes`                  | Configure the paths for the authentication routes. See [Custom routes](#custom-routes) for additional details.                                                                                                                         |\n| allowInsecureRequests       | `boolean`                 | Allow insecure requests to be made to the authorization server. This can be useful when testing with a mock OIDC provider that does not support TLS, locally. This option can only be used when `NODE_ENV` is not set to `production`. |\n| httpTimeout                 | `number`                  | Integer value for the HTTP timeout in milliseconds for authentication requests. Defaults to `5000` milliseconds                                                                                                                        |\n| enableTelemetry             | `boolean`                 | Boolean value to opt-out of sending the library name and version to your authorization server via the `Auth0-Client` header. Defaults to `true`.                                                                                       |\n\n## Routes\n\nThe SDK mounts 6 routes:\n\n1. `/auth/login`: the login route that the user will be redirected to to start a initiate an authentication transaction\n2. `/auth/logout`: the logout route that must be addedto your Auth0 application's Allowed Logout URLs\n3. `/auth/callback`: the callback route that must be addedto your Auth0 application's Allowed Callback URLs\n4. `/auth/profile`: the route to check the user's session and return their attributes\n5. `/auth/access-token`: the route to check the user's session and return an access token (which will be automatically refreshed if a refresh token is available)\n6. `/auth/backchannel-logout`: the route that will receive a `logout_token` when a configured Back-Channel Logout initiator occurs\n\n## Feedback\n\n### Contributing\n\nWe appreciate feedback and contribution to this repo! Before you get started, please read the following:\n\n- [Auth0's general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)\n- [Auth0's code of conduct guidelines](https://github.com/auth0/express-openid-connect/blob/master/CODE-OF-CONDUCT.md)\n- [This repo's contribution guide](./CONTRIBUTING.md)\n\n### Raise an issue\n\nTo provide feedback or report a bug, please [raise an issue on our issue tracker](https://github.com/auth0/nextjs-auth0/issues).\n\n## Vulnerability Reporting\n\nPlease do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/responsible-disclosure-policy) details the procedure for disclosing security issues.\n\n## What is Auth0?\n\n<p align=\"center\">\n  <picture>\n    <source media=\"(prefers-color-scheme: dark)\" srcset=\"https://cdn.auth0.com/website/sdks/logos/auth0_dark_mode.png\" width=\"150\">\n    <source media=\"(prefers-color-scheme: light)\" srcset=\"https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png\" width=\"150\">\n    <img alt=\"Auth0 Logo\" src=\"https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png\" width=\"150\">\n  </picture>\n</p>\n<p align=\"center\">\n  Auth0 is an easy to implement, adaptable authentication and authorization platform. To learn more checkout <a href=\"https://auth0.com/why-auth0\">Why Auth0?</a>\n</p>\n<p align=\"center\">\n  This project is licensed under the MIT license. See the <a href=\"https://github.com/auth0/express-openid-connect/blob/master/LICENSE\"> LICENSE</a> file for more info.\n</p>\n","readmeFilename":"README.md"}