claude-3.5-sonnetctx: 4,096 tokens
you
14:22
Can you explain how the routing system works in this template?
claude-3.5-sonnet
1/2
14:22The template uses TanStack Router with file-based routing. Each file in
Layout routes use the
The root layout (
src/routes/ becomes a route automatically.Layout routes use the
_ prefix — they wrap child routes via <Outlet /> without adding a URL segment. For example, _sidebar.tsx provides the sidebar shell for all routes under _sidebar/.The root layout (
__root.tsx) provides the outermost wrapper.you
14:23
What about data fetching?
claude-3.5-sonnet
14:23
Data fetching uses React Query (
API calls go through typed helpers in
In dev, requests to
@tanstack/react-query). The QueryClient is created in main.tsx and passed through context.API calls go through typed helpers in
lib/api.ts:const data = await get<MyType>("/endpoint")In dev, requests to
/api/* are intercepted by a Vite plugin and routed to the Hono server in-process — no CORS, no proxy, no separate server process.you
14:24
Nice. How would I add a new API endpoint?
claude-3.5-sonnet
14:24
Add a route handler in
That's it. The Vite plugin picks it up immediately in dev. In production,
api.ts:app.get("/api/my-endpoint", (c) => {
return c.json({ message: "hello" })
})That's it. The Vite plugin picks it up immediately in dev. In production,
server.ts serves the Hono app directly.