The
@hexclave/tanstack-start package is currently alpha. Pin exact package versions before shipping production apps.Setup
1
Create or open a TanStack Start app
If you do not have a TanStack Start app yet, create one with the TanStack CLI:TanStack also publishes official examples if you prefer to start from a working project.
Terminal
2
Install Hexclave
Install the alpha TanStack Start package:
Terminal
3
Create Hexclave keys
In the Hexclave dashboard, create a project and add these variables to your TanStack Start environment:Keep
.env
HEXCLAVE_SECRET_SERVER_KEY server-only. Do not expose it to client code.4
Create a Stack client app
Create a Stack client app with cookie storage:
src/stack/client.ts
5
Wrap the root route
Add
HexclaveProvider and HexclaveTheme around your route outlet:src/routes/__root.tsx
6
Add the auth handler route
Create a splat route at
/handler/* for Hexclave’s built-in pages:src/routes/handler/$.tsx
7
Use auth in routes
Use Stack hooks from inside components rendered under the provider:Routes that use browser redirects should render on the client:
src/routes/index.tsx
src/routes/protected.tsx
Notes
- The handler route must stay under the same origin as your app when using
tokenStore: "cookie". - Render the handler route on the client (
ssr: false) because built-in auth pages read browser location state. - Render routes that rely on
useUser({ or: "redirect" })on the client (ssr: false) when usingredirectMethod: "window". - Use
redirectMethod: "window"unless you explicitly wire a TanStack Router navigation adapter. - If you change auth routes, configure the matching
urlsonHexclaveClientApp. - For server-only logic, use TanStack Start server functions and keep
HEXCLAVE_SECRET_SERVER_KEYout of client modules.