Skip to main content
better-router is ESM. Use "module": "ESNext" and "moduleResolution": "bundler" so import attributes (islands) and .ts extensions in generated code typecheck.

tsconfig.json

tsconfig.json
src/vite-env.d.ts
.better-router is generated on vite build (route manifest). Include it if you want that file in the project; it is gitignored.

Loader and page types

There is no generated route type yet. Share a props type between the loader and the page:
src/routes/projects/[id].server.tsx
src/routes/projects/[id].tsx
On the first SSR pass, props come from the loader. After SPA navigation, useLoaderData() is the source of truth. Reading both (data.name ?? name) covers both. .server.tsx is server-only. Importing a type from it into a page is fine. Importing a value (a function, a database client) is not — that pulls server code into the client bundle.

Hono context and env

Loaders also receive c directly as LoaderArgs.c. Augment bindings and variables when you add Wrangler keys or middleware state:
src/env.d.ts
Then getEnv().DB and c.get("requestId") typecheck. See Bindings.

Client vs server imports