[GH-ISSUE #7932] Docs: add end-to-end guide for standalone Hono auth backend consumed by Next.js #10948

Open
opened 2026-04-13 07:20:42 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @Cali93 on GitHub (Feb 11, 2026).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/7932

What is missing?

The docs currently have separate pages for Hono integration and Next.js integration, but there is no end-to-end guide for this common architecture:

  • Better Auth mounted on a standalone Hono backend (different app/domain)
  • Next.js app consumes that backend as the frontend client

I checked:

Those pages contain useful pieces (CORS, cookies, Next handler/client), but not a single coherent walkthrough for "Hono backend + separate Next.js frontend".

Why this matters

Users can easily end up mixing patterns intended for:

  • Next.js hosting the auth handler itself (toNextJsHandler)
  • vs. Next.js consuming an external Better Auth API

This creates confusion around CORS, cookie domain/sameSite/secure settings, credentials: \"include\", and how SSR/session checks should be done when auth is on another origin.

Suggested docs addition

Please add a dedicated guide (or a section in integrations) that shows:

  1. Backend (Hono)

    • mount /api/auth/*
    • CORS with credentials: true and explicit origin
    • cookie config for same-domain, subdomain, and cross-site setups
  2. Frontend (Next.js consumer)

    • createAuthClient config for external base URL
    • client fetch credentials setup
    • how to do route protection/session retrieval when auth is external
    • what differs from the "Next.js hosts auth route" setup
  3. Architecture decision note

    • "If auth is hosted in Next.js, use X"
    • "If auth is hosted in Hono/external backend, use Y"

A minimal working example repo for this split architecture would be even better.

Originally created by @Cali93 on GitHub (Feb 11, 2026). Original GitHub issue: https://github.com/better-auth/better-auth/issues/7932 ### What is missing? The docs currently have separate pages for Hono integration and Next.js integration, but there is no end-to-end guide for this common architecture: - Better Auth mounted on a standalone Hono backend (different app/domain) - Next.js app consumes that backend as the frontend client I checked: - https://better-auth.com/docs/introduction - https://better-auth.com/docs/integrations/hono - https://better-auth.com/docs/integrations/next Those pages contain useful pieces (CORS, cookies, Next handler/client), but not a single coherent walkthrough for "Hono backend + separate Next.js frontend". ### Why this matters Users can easily end up mixing patterns intended for: - Next.js hosting the auth handler itself (`toNextJsHandler`) - vs. Next.js consuming an external Better Auth API This creates confusion around CORS, cookie domain/sameSite/secure settings, `credentials: \"include\"`, and how SSR/session checks should be done when auth is on another origin. ### Suggested docs addition Please add a dedicated guide (or a section in integrations) that shows: 1. **Backend (Hono)** - mount `/api/auth/*` - CORS with `credentials: true` and explicit origin - cookie config for same-domain, subdomain, and cross-site setups 2. **Frontend (Next.js consumer)** - `createAuthClient` config for external base URL - client fetch credentials setup - how to do route protection/session retrieval when auth is external - what differs from the "Next.js hosts auth route" setup 3. **Architecture decision note** - "If auth is hosted in Next.js, use X" - "If auth is hosted in Hono/external backend, use Y" A minimal working example repo for this split architecture would be even better.
GiteaMirror added the docsplatform labels 2026-04-13 07:20:42 -05:00
Author
Owner

@better-auth-agent[bot] commented on GitHub (Feb 11, 2026):

Thank you for bringing up this important issue regarding the integration of a standalone Hono backend with a Next.js frontend in the Better Auth documentation. Currently, there is no dedicated end-to-end guide that addresses this architecture directly, though individual sections for Hono and Next.js integrations exist.

Suggested Next Steps:

  1. Documentation Review: I'll make sure to pass along your suggestion to the documentation team. It would be beneficial to create a comprehensive guide covering:

    • How to properly set up a Hono backend that includes CORS configurations, cookie settings, etc.
    • Instructions on how Next.js can effectively communicate with this external backend, including session management and route protection.
  2. The Community's Input: While waiting for an official guide, I recommend checking existing resources on proper authentication practices in both Hono and Next.js. Community members who have implemented similar setups might also have shared their experiences in forums or Github discussions.

  3. Minimal Example: A minimal working repository demonstrating your proposed setup would indeed be a great addition that could benefit others in the community.

Please feel free to tag @better-auth-agent for more detailed assistance or any kind of support. What specific area of the integration are you looking to work on first?

If you need more help, tag @better-auth-agent in a comment so I can respond.

Diagram • Discord • GitHub

Diagram Join Star

<!-- gh-comment-id:3887489553 --> @better-auth-agent[bot] commented on GitHub (Feb 11, 2026): Thank you for bringing up this important issue regarding the integration of a standalone Hono backend with a Next.js frontend in the Better Auth documentation. Currently, there is no dedicated end-to-end guide that addresses this architecture directly, though individual sections for Hono and Next.js integrations exist. ### Suggested Next Steps: 1. **Documentation Review**: I'll make sure to pass along your suggestion to the documentation team. It would be beneficial to create a comprehensive guide covering: - How to properly set up a Hono backend that includes CORS configurations, cookie settings, etc. - Instructions on how Next.js can effectively communicate with this external backend, including session management and route protection. 2. **The Community's Input**: While waiting for an official guide, I recommend checking existing resources on proper authentication practices in both Hono and Next.js. Community members who have implemented similar setups might also have shared their experiences in forums or Github discussions. 3. **Minimal Example**: A minimal working repository demonstrating your proposed setup would indeed be a great addition that could benefit others in the community. Please feel free to tag @better-auth-agent for more detailed assistance or any kind of support. What specific area of the integration are you looking to work on first? _If you need more help, tag @better-auth-agent in a comment so I can respond._ <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) • [Discord](https://discord.gg/better-auth) • [GitHub](https://github.com/better-auth/better-auth) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/better-auth) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/better-auth/better-auth)
Author
Owner

@adwait50 commented on GitHub (Feb 13, 2026):

I’d like to work on this documentation guide.
I plan to add a step-by-step standalone Hono + Next.js auth walkthrough.
Let me know if you have any preferences on structure or placement.

<!-- gh-comment-id:3897701059 --> @adwait50 commented on GitHub (Feb 13, 2026): I’d like to work on this documentation guide. I plan to add a step-by-step standalone Hono + Next.js auth walkthrough. Let me know if you have any preferences on structure or placement.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#10948