A lightweight, promise-based session middleware for Next.js, Express, micro, and Node.js HTTP servers.
next-session is a lightweight, promise-based session middleware for Node.js frameworks like Next.js, Express, and micro. It enables server-side session management by providing a simple API to store and retrieve user data across requests, solving state persistence in stateless server environments.
Developers building applications with Next.js, Express, or micro who need straightforward session handling for features like user authentication, shopping carts, or personalized content.
It offers a minimal, framework-agnostic solution with a promise-based API, production-ready store compatibility, and optimized performance features like touchAfter, making it a reliable choice over heavier alternatives.
Simple promise-based session middleware for Next.js, micro, Express, and more
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses async/await for session operations, making code cleaner and easier to integrate with asynchronous workflows, as demonstrated in all usage examples.
Seamlessly works with Next.js API routes, getServerSideProps, Express, micro, and Node.js HTTP servers, shown in the multi-framework usage sections.
Supports custom stores and provides promisifyStore for Express/Connect compatibility, enabling production-ready setups with databases like Redis.
Includes touchAfter to reduce database load by limiting touches on unmodified sessions, optimizing for high-traffic applications.
Allows disabling autoCommit for manual commit, destroy, and touch operations, giving fine-grained control over session lifecycle.
The default MemoryStore is explicitly warned against for production, forcing developers to set up an external store, adding setup complexity.
Multiple major version updates (v1 to v4) have breaking changes, requiring careful migration and reading of release notes, as highlighted in the README.
Can cause 'API resolved without sending a response' errors in Next.js API routes, necessitating workarounds like externalResolver or manual commit.
Lacks built-in encryption for session data; security enhancements depend on custom encode/decode functions or external store implementations.