8.0.0
The v8 of iron-session focuses on reducing its API surface and bringing compatibility with the Next.js App Router.
As long as you make the required code changes, this upgrade will not disconnect your customers once deployed.
Instead of multiple opinionated wrappers (withIronSess..
) There's now a single method to get sessions: getIronSession()
.
Use it like this:
import { getIronSession } from "iron-session";
const session = getIronSession(req, res, { password: "...", cookieName: "..." });
// or, in App Router:
const session = getIronSession(cookies(), { password: "...", cookieName: "..." });
Read more in the README: https://github.com/vvo/iron-session#usage.
Have a look at our new examples:
New features:
- App Router compatibility
updateConfig
method to change a session configuration for the nextsave()
ordestroy()
- Single entry point, no more
/next
,/edge
, ..
BREAKING CHANGES:
- We've removed support for Node.js < 18
- We've removed
withIronSessionApiRoute
,withIronSessionSsr
,ironSession
- added support
Gigantic thanks to:
- @brc-dd for creating https://github.com/brc-dd/iron-webcrypto, doing most of the work of the b8 branch and being of great help while designing the API!
- @renchris for making the adapter to support server components, server actions and route handlers.