-
Perhaps I'm missing something, but it seems that the // Next.js Server Components and Server Actions (App Router)
import { cookies } from 'next/headers';
import { getIronSession } from 'iron-session';
// ↓↓↓ NO RETURN VALUE ↓↓↓
async function getIronSessionData() {
const session = await getIronSession(cookies(), { password: "...", cookieName: "..." });
}
function Profile() {
// ↓↓↓ ASSIGNMENT ↓↓↓
const session = await getIronSessionData();
return <div>{session.username}</div>;
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I have the same problem. I'm very confused. I get an empty session object if I call Is nobody else having issues? |
Beta Was this translation helpful? Give feedback.
-
Hey there, sorry I messed up the README, it's now fixed: export async function get(req, res) {
const session = await getIronSession(req, res, { password: "...", cookieName: "..." });
return session;
} |
Beta Was this translation helpful? Give feedback.
Hey there, sorry I messed up the README, it's now fixed:
https://github.com/vvo/iron-session