@kikiutils/nuxt-session v4.0.1
@kikiutils/nuxt-session
Easy-to-use nuxt server-side session.
Features
- 🔄 Continuous session between requests using a cookie or header
- 🌐 Available in server-side middleware
- 💾 Auto-save session
- 📦 Store session data using a cookie, header, or unjs/unstorage drivers
- 🔒 Optional strict IP validation to ensure session security
- 🛠️ TypeScript support
Environment Requirements
- Nuxt version 3.9.x or higher, but below 4.x
- Node.js version 18 or higher
Installation
- Add dependency (example using pnpm).
pnpm add @kikiutils/nuxt-sessionYou can also use yarn, npm, or bun to add the dependency.
- Add this module to the
modulesfield innuxt.config.ts:
export default defineNuxtConfig({ modules: ['@kikiutils/nuxt-session'] });- Create a
session.d.tsfile in theserverfolder under the project directory and and add the following code:
declare module '@kikiutils/nuxt-session' {
interface H3EventContextSession {
// Define the session data here.
}
}
export {};That's it! You're ready to use sessions in your Nuxt app. Check out the configuration and usage instructions below ✨.
Configuration
Configure using nuxtSession in nuxt.config.ts.
export default defineNuxtConfig({ nuxtSession: {} });This package uses @kikiutils/nitro-session as its core. For related configuration instructions, please refer to this link.
Except for the configuration method mentioned above, all other options remain the same.
Usage
Please refer to this link for related usage.
!IMPORTANT This package is intended for use in the
serverfolder of Nuxt. For more information about this folder, please see this link.Only requests with paths starting with
/apiwill handle sessions.
Server Runtime Utils
Please refer to this link for related server runtime utils.
License
11 months ago
8 months ago
8 months ago
11 months ago
7 months ago
7 months ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago