TanStackT
TanStack14mo ago
6 replies
colossal-harlequin

Putting auth context in RouterProvider context gives errors

I'm wanting to put the authClient of better-auth into the context of RouterProvider.

I get the error found in the first image.

From the better-auth dev:
I think It's cause tanstack tries to call toJSON on the objects you pass to the context.

Unfortunately, my current stack is complex:

- Electron
- Vite
- Tanstack Router
- Hono.js
- Pglite DB server
- Drizzle (Electron+Hono.js)
- Better-auth

So I have reduced it now to:
- Tanstack Router
- Hono.js
- Turso
- Better-auth

Here is the repo:
https://github.com/paulm17/router-hono

- pnpm i
- pnpm run dev (both hono and router will start)
- navigate to http://localhost:5173
- open up dev tools for the redirected login page and you'll see the second image

@Manuel Schiller
Screenshot_2024-12-05_at_16.png
Screenshot_2024-12-07_at_11.09.50.png
Was this page helpful?