Search documentation

Find a page in the Andurel docs.

TypeScript Sync

Inertia projects keep Go routes and controller payloads as the source of truth. andurel sync writes matching TypeScript helpers without creating application-owned Go files.

Routes

1andurel inspect routes --json
2andurel sync routes
3andurel sync routes --json

sync routes writes resources/js/routes.ts from the route manifest. Mark routes that should appear in the TypeScript helpers with routing.InertiaRoute() when declaring them.

Sample --json envelope:

 1{
 2  "ok": true,
 3  "data": {
 4    "generated_file": "resources/js/routes.ts",
 5    "generated_helpers": 13,
 6    "skipped_count": 4,
 7    "skipped": [
 8      {
 9        "variable": "ViteBuild",
10        "reason": "route path is not a static string expression"
11      }
12    ]
13  },
14  "summary": "Generated 13 route helpers to resources/js/routes.ts (4 skipped)"
15}

Generated helper shape:

 1// Code generated by andurel; DO NOT EDIT.
 2
 3type HostOrigins = Record<string, string>
 4
 5export function configureRouteHosts(next: HostOrigins) { /* ... */ }
 6
 7export const routes = {
 8  projectShow: routeHelper({
 9    host: 'primary',
10    path: (id: string) => `/projects/${id}`,
11  }),
12  sessionNew: routeHelper({
13    host: 'primary',
14    path: () => '/users/sign-in',
15  }),
16}

Call configureRouteHosts once at boot with the shared hosts prop (resources/js/app and the SSR entry). After that, routes.projectShow(id) returns a full URL for the bound host. Use routes.projectShow.path(id) for a relative path.

Import helpers via @/routes in pages and layouts:

1import { routes } from "@/routes"
2import { router } from "@inertiajs/react"
3
4router.visit(routes.projectShow.path(product.id))

Payloads

1andurel sync payloads
2andurel sync payloads --json

sync payloads writes TypeScript types for controller payload / bind structs under resources/js/types/payloads.ts.

1{
2  "ok": true,
3  "data": {
4    "generated_file": "resources/js/types/payloads.ts",
5    "type_count": 5,
6    "skipped_count": 0
7  },
8  "summary": "Generated 5 payload types to resources/js/types/payloads.ts"
9}

Snippet of generated types:

 1// Code generated by andurel; DO NOT EDIT.
 2
 3export type ProjectData = {
 4  id: string
 5  title: string
 6  status: string
 7  createdAt: string | null
 8  updatedAt: string | null
 9}
10
11export type ProjectIndexProps = {
12  items: ProjectData[]
13}
14
15export type CreateProjectFormPayload = {
16  title: string
17  status: string
18}

Keep JSON tags stable and avoid serializing database rows directly. See Props.

Scaffolding pages and controllers remains under Generators and generate. Use sync for the full derived-artifact surface (views, queries, email, factories).