How to Use the Better Auth nextCookies Plugin in Next.js
Without the nextCookies plugin, a sign-in that runs in a Next.js server action never reaches the browser. Add the plugin, and the cookie arrives.
- Web Application
- Better Auth
Without the nextCookies plugin, a sign-in that runs in a Next.js server action never reaches the browser. Add the plugin, and the cookie arrives.
A server action can be called by anyone, so it checks the Better Auth session itself. Here’s the pattern, with a form that changes a display name.
Check the Better Auth session on the server in Next.js 16: a private account page, an early redirect in proxy.ts, a sign-out server action and an API route that answers 401.