Gathering detailed insights and metrics for nestjs-cookie-session
Gathering detailed insights and metrics for nestjs-cookie-session
Gathering detailed insights and metrics for nestjs-cookie-session
Gathering detailed insights and metrics for nestjs-cookie-session
@nest-middlewares/cookie-session
NestJS Middleware for Cookie Session
@nest-middleware-collection/cookie-session
NestJS Middleware for Cookie Session
@next-nest-auth/nextauth
NextAuth is a frontend authentication package designed for Next.js applications, providing easy integration with NestJS-based backends. It supports login, session management, and token handling (including JWT and refresh tokens) to ensure secure user auth
Idiomatic Cookie Session Module for NestJS. Built on top of `cookie-session` 😻
npm install nestjs-cookie-session
Typescript
Module System
Min. Node Version
Node Version
NPM Version
4.0.0: nestjs@11 support
Updated on Jan 23, 2025
3.0.1: fix nest@8 compatibility of useFactory return type
Updated on Aug 17, 2023
3.0.0: drop support of nestjs<8 and node<16, update ci, deps, readme
Updated on Aug 16, 2023
2.0.1: add License and strict engine check
Updated on Aug 30, 2021
2.0.0: nestjs6+ support
Updated on Aug 30, 2021
JavaScript (58.12%)
TypeScript (41.88%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
54 Stars
1,411 Commits
3 Forks
2 Watchers
15 Branches
4 Contributors
Updated on Jul 01, 2025
Latest Version
4.0.0
Package Id
nestjs-cookie-session@4.0.0
Unpacked Size
9.74 kB
Size
3.74 kB
File Count
5
NPM Version
10.9.2
Node Version
22.13.0
Published on
Jan 23, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
2
27
Idiomatic Cookie Session Module for NestJS. Built on top of cookie-session 😎
This module implements a session with storing data directly in Cookie
.
If you want to store data in one of external stores and passing ID of session to client via Cookie
/Set-Cookie
headers, you can look at nestjs-session.
Register module:
1// app.module.ts 2import { Module } from '@nestjs/common'; 3import { 4 NestCookieSessionOptions, 5 CookieSessionModule, 6} from 'nestjs-cookie-session'; 7import { ViewsController } from './views.controller'; 8 9@Module({ 10 imports: [ 11 // sync params: 12 13 CookieSessionModule.forRoot({ 14 session: { secret: 'keyboard cat' }, 15 }), 16 17 // or async: 18 19 CookieSessionModule.forRootAsync({ 20 imports: [ConfigModule], 21 inject: [Config], 22 // TIP: to get autocomplete in return object 23 // add `NestCookieSessionOptions` here ↓↓↓ 24 useFactory: async (config: Config): Promise<NestCookieSessionOptions> => { 25 return { 26 session: { secret: config.secret }, 27 }; 28 }, 29 }), 30 ], 31 controllers: [ViewsController], 32}) 33export class AppModule {}
Use in controllers with NestJS built-in Session
decorator:
1// views.controller.ts 2import { Controller, Get, Session } from '@nestjs/common'; 3 4@Controller('views') 5export class ViewsController { 6 @Get() 7 getViews(@Session() session: { views?: number }) { 8 session.views = (session.views || 0) + 1; 9 return session.views; 10 } 11}
To run examples:
1git clone https://github.com/iamolegga/nestjs-cookie-session.git 2cd nestjs-cookie-session 3npm i 4npm run build 5cd example 6npm i 7npm start
1npm i nestjs-cookie-session cookie-session @types/cookie-session
CookieSessionModule
class has two static methods, that returns DynamicModule
, that you need to import:
CookieSessionModule.forRoot
for sync configuration without dependenciesCookieSessionModule.forRootAsync
for sync/async configuration with dependenciesAccept NestCookieSessionOptions
. Returns NestJS DynamicModule
for import.
Accept NestCookieSessionAsyncOptions
. Returns NestJS DynamicModule
for import.
NestCookieSessionOptions
is the interface of all options, has next properties:
session
- required - cookie-session options.forRoutes
- optional - same as NestJS built-in MiddlewareConfigProxy['forRoutes']
See examples in official docs. Specify routes, that should have access to session. If forRoutes
and exclude
will not be set, then sessions will be set to all routes.exclude
- optional - same as NestJS built-in MiddlewareConfigProxy['exclude']
See examples in official docs. Specify routes, that should not have access to session. If forRoutes
and exclude
will not be set, then sessions will be set to all routes.NestCookieSessionOptions
is the interface of options to create cookie session module, that depends on other modules, has next properties:
imports
- optional - modules, that cookie session module depends on. See official docs.inject
- optional - providers from imports
-property modules, that will be passed as arguments to useFactory
method.useFactory
- required - method, that returns NestCookieSessionOptions
.cookie-session
and @types/cookie-session
are moved to peer dependencies, so you can update them independently.
No vulnerabilities found.
Reason
22 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 4
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
10 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More