CLI Tools
omni-rest ships two CLIs:
omni-rest— backend generators (Prisma-aware). Produces Zod schemas, OpenAPI specs, and the shared config file.omni-rest-client— frontend generator (no Prisma). Reads the config file and scaffolds React components.
omni-rest (backend CLI)
Run these from any directory that contains a schema.prisma file (or has one in a parent directory).
npx omni-rest generate:configWrites omni-rest.config.json — a portable JSON file containing all model metadata and Zod schema source. This is the bridge between the backend and omni-rest-client.
{
"version": "1",
"generatedAt": "2026-03-29T10:00:00.000Z",
"models": [
{
"name": "User",
"routeName": "user",
"idField": "id",
"fields": [...]
}
],
"zodSchemas": "import { z } from 'zod';\n\nexport const UserCreateSchema = ..."
}Re-run this command any time your Prisma schema changes, then re-run npx omni-rest-client generate:frontend in your frontend project.
omni-rest-client (frontend CLI)
Reads omni-rest.config.json and generates a complete React data layer — no Prisma, no schema.prisma, no DB connection needed.
npx omni-rest-client generate:frontendQuick example
Given a User model in your config, the generator produces:
- schemas.generated.ts
- useUser.ts
- UserColumns.tsx
- UserTable.tsx
- UserForm.tsx
- data-table.tsx
- form-generator.tsx
- providers.tsx
- menu-data.ts
Drop the components into a page:
import { UserTable } from '@/src/components/user/UserTable'
export default function UsersPage() {
return (
<div className="container mx-auto py-10">
<h1 className="text-3xl font-bold mb-6">Users</h1>
<UserTable />
</div>
)
}Full workflow
Set up your backend
npx prisma generate
npx omni-rest generate # Zod schemas + OpenAPI spec
npx omni-rest generate:config # omni-rest.config.jsonInstall frontend dependencies
npm install -D omni-rest-client
npm install @tanstack/react-query @tanstack/react-table \
react-hook-form zod @hookform/resolversGenerate frontend code
# Reference the config from your backend (monorepo example)
npx omni-rest-client generate:frontend \
--config ../backend/omni-rest.config.json \
--autopilotAdd the providers wrapper
// app/layout.tsx
import { Providers } from '@/src/components/providers'
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html>
<body>
<Providers>{children}</Providers>
</body>
</html>
)
}Use the generated components
// app/users/page.tsx
import { UserTable } from '@/src/components/user/UserTable'
export default function UsersPage() {
return (
<div className="container mx-auto py-10">
<UserTable />
</div>
)
}Re-run after schema changes
# Backend
npx prisma generate
npx omni-rest generate:config
# Frontend
npx omni-rest-client generate:frontend --autopilotHook and column files are overwritten on each run. The shared base components (data-table.tsx, form-generator.tsx) are skipped if they already exist, preserving any customizations.
omni-rest-client flags
| Flag | Default | Description |
|---|---|---|
--config <path> | ./omni-rest.config.json | Path to config file |
--frontend-dir <path> | cwd | Frontend project root |
--out <dir> | src/ or root | Output directory |
--models <names> | all | Comma-separated model names |
--base-url <url> | /api | API base URL |
--framework <name> | auto-detect | nextjs | vite-react | react |
--autopilot | false | Skip all prompts |
--no-bulk | — | Disable bulk delete |
--no-optimistic | — | Disable optimistic updates |
--no-pages | — | Disable Next.js page generation |
--no-menu | — | Disable menu-data.ts |
--no-schemas | — | Skip writing schemas.generated.ts |
--steps <mode> | auto | auto | always | never |
--stale-time <ms> | 30000 | TanStack Query staleTime |
--gc-time <ms> | 300000 | TanStack Query gcTime |
--help | — | Print usage |