HonoJS backend and NextJS frontend

@Better Auth I am having experiencing difficulty in setting up better-auth client for the frontend part. Can anybody please help with this
3 Replies
Better Auth
Better Auth•18h ago
I'd be happy to help you set up the Better Auth client for your frontend! Let me guide you through the process. Basic Client Setup First, you'll need to install Better Auth if you haven't already:
npm i better-auth
npm i better-auth
Then, create a client instance by importing createAuthClient from the package specific to your framework [1]: For React:
import { createAuthClient } from "better-auth/react"

export const authClient = createAuthClient({
baseURL: "http://localhost:3000" // Your auth server URL
})
import { createAuthClient } from "better-auth/react"

export const authClient = createAuthClient({
baseURL: "http://localhost:3000" // Your auth server URL
})
For Vue:
import { createAuthClient } from "better-auth/vue"

export const authClient = createAuthClient()
import { createAuthClient } from "better-auth/vue"

export const authClient = createAuthClient()
For Svelte:
import { createAuthClient } from "better-auth/svelte"

export const authClient = createAuthClient()
import { createAuthClient } from "better-auth/svelte"

export const authClient = createAuthClient()
For vanilla JavaScript:
import { createAuthClient } from "better-auth/client"

export const authClient = createAuthClient()
import { createAuthClient } from "better-auth/client"

export const authClient = createAuthClient()
Important Configuration Notes - If your auth server is running on a different domain than your client, you must pass the baseURL option [1] - If you're using a different base path other than /api/auth, make sure to pass the whole URL including the path [1] - The client provides hooks (starting with use) for reactive data access in supported frameworks [1] Common Issues to Check Based on common setup issues, here are a few things to verify: 1. CORS Configuration: If you're running your frontend and backend on different ports/domains, ensure CORS is properly configured on your backend 2. Base URL: Make sure your baseURL points to where your Better Auth handler is mounted (typically http://localhost:3000 for local development)
Client | Better Auth
Better Auth client library for authentication.
Better Auth
Better Auth•18h ago
[23] 3. Framework-specific Import: Ensure you're importing from the correct package for your framework (e.g., better-auth/react for React, not just better-auth/client) [1] Could you share more details about what specific error or issue you're encountering? For example: - What framework are you using (React, Vue, Svelte, etc.)? - Are you getting any error messages? - Is your backend on the same domain as your frontend, or are they separate? This will help me provide more targeted assistance! If you continue to have issues, feel free to tag <@bekacru> and <@ping__> who are the Better Auth team members and can provide additional support. Sources: [1] Client | Better Auth [23] Basic sign up setup results in 404 for the endpoint "api/auth/sign-up/email" — Better Auth is powered by https://clarm.com
GitHub
Basic sign up setup results in 404 for the endpoint "api/auth/sign-...
Is this suited for github? Yes, this is suited for github To Reproduce Follow these steps https://www.better-auth.com/docs/installation and I&#39;m using Prisma + Express JS Call the signup functio...
Client | Better Auth
Better Auth client library for authentication.

Did you find this page helpful?