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


6 Replies
optimistic-gold•10mo ago
this comes from the router dev tools
optimistic-gold•10mo ago
GitHub
router/packages/router-devtools/src/utils.ts at main · TanStack/rou...
🤖 Fully typesafe Router for React (and friends) w/ built-in caching, 1st class search-param APIs, client-side cache integration and isomorphic rendering. - TanStack/router
optimistic-gold•10mo ago

optimistic-gold•10mo ago
the devtools try to display the context by serializing it to JSON
extended-salmonOP•10mo ago
You know it's weird. After all this troubleshooting with the better-auth dev and now asking yourself to look at it.
It's now working with my other stack. It gets to the login page just fine. 🤷♂️
Anyway, thanks for getting to the bottom of this.
optimistic-gold•10mo ago
I will try to make the dev tools a bit more robust but a Proxy cannot be detected reliably