Skip to content

Latest commit

 

History

History
12 lines (7 loc) · 798 Bytes

File metadata and controls

12 lines (7 loc) · 798 Bytes

Better Auth Separate Backend Example

This repository was created to share a personal convention for using Better Auth on a separate backend. Since using the Auth Client on the server-side requires a bit of extra setup, this approach shows a convenient way to separate the usage.

Structure

  • Hono: API server that includes the Auth instance
  • Next.js: Client app that interacts with the API server using the Auth Client instance

Idea

In frameworks like Next.js, the server-side and client-side are separated, so we manage the Auth Client instance separately for each side. When performing auth checks on the server side, you can protect resources without dealing with loading states. This approach is my preferred way of using Better Auth, and this repository reflects that convention.