[GH-ISSUE #2312] Request auth.api.getSession example for Next.js pages router #9143

Closed
opened 2026-04-13 04:30:02 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @rinarakaki on GitHub (Apr 16, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/2312

Is this suited for github?

  • Yes, this is suited for github

No response

Describe the solution you'd like

https://www.better-auth.com/docs/guides/next-auth-migration-guide#server-side-session-handling

Describe alternatives you've considered

N/A

Additional context

No response

Originally created by @rinarakaki on GitHub (Apr 16, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/2312 ### Is this suited for github? - [ ] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. _No response_ ### Describe the solution you'd like https://www.better-auth.com/docs/guides/next-auth-migration-guide#server-side-session-handling ### Describe alternatives you've considered N/A ### Additional context _No response_
GiteaMirror added the locked label 2026-04-13 04:30:02 -05:00
Author
Owner

@Kinfe123 commented on GitHub (May 29, 2025):

you can use for api routes

import { auth } from "@/lib/auth"
import { toNodeHandler } from "better-auth/node"

export const config = { api: { bodyParser: false } }
export default toNodeHandler(auth.handler)
<!-- gh-comment-id:2918332642 --> @Kinfe123 commented on GitHub (May 29, 2025): you can use for api routes ```ts import { auth } from "@/lib/auth" import { toNodeHandler } from "better-auth/node" export const config = { api: { bodyParser: false } } export default toNodeHandler(auth.handler) ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#9143