nuxt-session-middleware
v0.1.0
Published
Simple session module for Nuxt
Downloads
12
Maintainers
Readme
nuxt-session-middleware
Add session support in Nuxt 3 using express-session.
Installation
npm install nuxt-session-middleware
Usage
export default defineNuxtConfig({
modules: ['nuxt-session-middleware'],
session: {
secret: 'keyboard cat',
resave: false,
saveUninitialized: true,
cookie: { secure: true }
}
})
export default defineEventHandler(({ req }) => {
// Get the session ID:
console.log(req.session.id)
// Assign some value to session:
req.session.someKey = 'some value'
})
Visit the express-session docs to see the complete session configuration.
TypeScript
Typing the session property
declare module 'h3' {
interface CompatibilityEvent {
req: IncomingMessage & {
session: {
views: number
}
}
}
}
License
MIT