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
 3export const routes = {
 4  projectCreate: () => '/projects',
 5  projectDestroy: (id: string) => `/projects/${id}`,
 6  projectEdit: (id: string) => `/projects/${id}/edit`,
 7  projectIndex: () => '/projects',
 8  projectNew: () => '/projects/new',
 9  projectShow: (id: string) => `/projects/${id}`,
10  projectUpdate: (id: string) => `/projects/${id}`,
11  sessionNew: () => '/users/sign-in',
12}

Import helpers via @/routes in pages and layouts:

1import { routes } from "@/routes"
2import { router } from "@inertiajs/vue3"
3
4router.visit(routes.projectShow(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).