{"_id":"@dockethealth/supertokens-nestjs","name":"@dockethealth/supertokens-nestjs","dist-tags":{"latest":"0.0.5"},"versions":{"0.0.5":{"name":"@dockethealth/supertokens-nestjs","version":"0.0.5","description":"SuperTokens integration for NestJS applications","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"rimraf dist && tsc -p tsconfig.json","start:express":"(cd ./examples/react-frontend && npm run start) & (cd ./examples/express-backend && npm run start) & wait","start:fastify":"(cd ./examples/react-frontend && npm run start) & (cd ./examples/fastify-backend && npm run start) & wait","start:graphql":"(cd ./examples/react-frontend && npm run start) & (cd ./examples/graphql-backend && npm run start) & wait","test":"vitest run","test:watch":"vitest","changeset":"changeset","version":"changeset version","release":"npm run build && changeset publish","prepare":"husky"},"repository":{"type":"git","url":"git+https://github.com/dockethealth/supertokens-nestjs.git"},"exports":{".":{"types":"./index.d.ts","default":"./index.js"},"./index":{"types":"./index.d.ts","default":"./index.js"},"./index.js":{"types":"./index.d.ts","default":"./index.js"}},"keywords":["supertokens","nestjs","nodejs","authentication","session-management"],"license":"Apache-2.0","peerDependencies":{"@nestjs/core":"^11.0.1","@nestjs/platform-express":"^11.0.1","@nestjs/platform-fastify":"^11.0.6","supertokens-node":"^23.0.0"},"peerDependenciesMeta":{"@nestjs/platform-express":{"optional":true},"@nestjs/platform-fastify":{"optional":true}},"devDependencies":{"@changesets/cli":"^2.29.7","@commitlint/cli":"^19.8.1","@commitlint/config-conventional":"^19.8.1","@nestjs/apollo":"^13.0.4","@nestjs/graphql":"^13.0.4","@nestjs/platform-express":"^11.0.7","@nestjs/testing":"^11.0.7","@types/supertest":"^6.0.3","husky":"^9.1.7","npm-run-all":"^4.1.5","rimraf":"^6.0.1","supertest":"^7.0.0","typescript":"^5.7.3","vitest":"^3.0.4"},"gitHead":"79d3e43bb36696d0fc8b0f6a2d4d93d00082bbe1","_id":"@dockethealth/supertokens-nestjs@0.0.5","bugs":{"url":"https://github.com/dockethealth/supertokens-nestjs/issues"},"homepage":"https://github.com/dockethealth/supertokens-nestjs#readme","_nodeVersion":"20.18.3","_npmVersion":"11.6.2","dist":{"integrity":"sha512-BFM3rXSOX45TnqEoN4szLbE5c7ExHYrFjroPskp5EA+e0Ew3Cs8xkqZCH/q964/LdMhHBap6qCeng0Ek1nBQEg==","shasum":"b88d8f2b739226734da35a3a29f91baed8627fde","tarball":"https://registry.npmjs.org/@dockethealth/supertokens-nestjs/-/supertokens-nestjs-0.0.5.tgz","fileCount":147,"unpackedSize":2279418,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIAZrbtB9t9UQFj8uOPxFUopV6NZb/zmI1y1ESdixXOKBAiB1Z9cyCkBjtFqBudgNn0ZSaGfkJYK1KvP9OmGwLQuQ1g=="}]},"_npmUser":{"name":"nmead","email":"nick.mead@dockethealth.com"},"directories":{},"maintainers":[{"name":"packetjotato","email":"natedscott@gmail.com"},{"name":"joemac875","email":"joemacinnes@icloud.com"},{"name":"nmead","email":"nick.mead@dockethealth.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/supertokens-nestjs_0.0.5_1767644551551_0.8899512427935066"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-05T20:22:31.408Z","0.0.5":"2026-01-05T20:22:31.756Z","modified":"2026-01-05T20:22:32.095Z"},"maintainers":[{"name":"packetjotato","email":"natedscott@gmail.com"},{"name":"joemac875","email":"joemacinnes@icloud.com"},{"name":"nmead","email":"nick.mead@dockethealth.com"}],"description":"SuperTokens integration for NestJS applications","homepage":"https://github.com/dockethealth/supertokens-nestjs#readme","keywords":["supertokens","nestjs","nodejs","authentication","session-management"],"repository":{"type":"git","url":"git+https://github.com/dockethealth/supertokens-nestjs.git"},"bugs":{"url":"https://github.com/dockethealth/supertokens-nestjs/issues"},"license":"Apache-2.0","readme":"![SuperTokens banner](https://raw.githubusercontent.com/supertokens/supertokens-logo/master/images/Artboard%20%E2%80%93%2027%402x.png)\n\n# SuperTokens Nestjs\n\n<a href=\"https://supertokens.com/discord\">\n<img src=\"https://img.shields.io/discord/603466164219281420.svg?logo=discord\"\n    alt=\"chat on Discord\"></a>\n\n## Description\n\nThe library makes it easier to use SuperTokens in NestJS applications.\nIt does that by exposing NestJS entities (modules, guards, decorators, etc.) which abstract some of the logic that a user would normally need to write by themselves.\nThat being said, the library **does not** include any additional functionality besides what you can create with the SuperTokens Node SDK.\n\n## Usage\n\n### 1. Install the dependencies\n\n```bash\nnpm install supertokens-node supertokens-nestjs\n```\n\n### 2. Initialize the `SuperTokensModule` inside your main application module\n\n```ts\nimport { Module } from '@nestjs/common'\nimport { SuperTokensModule } from 'supertokens-nestjs'\n\n@Module({\n  imports: [\n    SuperTokensModule.forRoot({\n      framework: 'express',\n      supertokens: {\n        connectionURI: '...',\n      },\n      appInfo: {\n        appName: '...',\n        apiDomain: '...',\n        websiteDomain: '...',\n      },\n      recipeList: [\n        /* ... */\n      ],\n    }),\n  ],\n  controllers: [\n    /* ... */\n  ],\n  providers: [\n    /* ... */\n  ],\n})\nexport class AppModule {}\n```\n\n### 3. Add the `SuperTokensAuthGuard` to protect your routes\n\n#### Option 1: As a global guard\n\n```ts\nimport { Module } from '@nestjs/common'\nimport { APP_GUARD } from '@nestjs/core'\nimport { SuperTokensAuthGuard } from 'supertokens-nestjs'\n\n@Module({\n  imports: [\n    /* ... */\n  ],\n  controllers: [\n    /* ... */\n  ],\n  providers: [\n    {\n      provide: APP_GUARD,\n      useClass: SuperTokensAuthGuard,\n    },\n  ],\n})\nexport class AppModule {}\n```\n\n#### Option 2: As a controller guard\n\n```ts\nimport { Controller, UseGuards } from '@nestjs/common'\nimport { SuperTokensAuthGuard } from 'supertokens-nestjs'\n\n@Controller()\n@UseGuards(SuperTokensAuthGuard)\nexport class AppController {}\n```\n\n### 4. Add the CORS config and the exception filter in your `bootstrap` function\n\n```ts\nimport supertokens from 'supertokens-node'\nimport { SuperTokensExceptionFilter } from 'supertokens-nestjs'\nimport { appInfo } from './config'\n\nasync function bootstrap() {\n  const app = await NestFactory.create(AppModule)\n  app.enableCors({\n    origin: [appInfo.websiteDomain],\n    allowedHeaders: ['content-type', ...supertokens.getAllCORSHeaders()],\n    credentials: true,\n  })\n  app.useGlobalFilters(new SuperTokensExceptionFilter())\n\n  await app.listen(3001)\n}\n```\n\n### 5. Use the provided decorators to customize the route protection logic and access the authentication state\n\n```ts\nimport { Controller, Delete, Get, Patch, Post } from '@nestjs/common'\nimport { PublicAccess, Session, VerifySession } from 'supertokens-nestjs'\n\n@Controller()\nclass AppController {\n  @Get('/user')\n  @VerifySession()\n  async getUserInfo(@Session('userId') userId: string) {}\n\n  @Get('/user/:userId')\n  @VerifySession({\n    roles: ['admin'],\n  })\n  async deleteUser() {}\n\n  @Get('/user/profile')\n  @PublicAccess()\n  async getUserProfile() {}\n}\n```\n","readmeFilename":"README.md","_rev":"1-30dd72d3edb4765b8b1779a0e1fbe36b"}