Documentation
CLI Tools

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:config

Writes 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:frontend

Quick 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.json

    Install frontend dependencies

    npm install -D omni-rest-client
    npm install @tanstack/react-query @tanstack/react-table \
      react-hook-form zod @hookform/resolvers

    Generate frontend code

    # Reference the config from your backend (monorepo example)
    npx omni-rest-client generate:frontend \
      --config ../backend/omni-rest.config.json \
      --autopilot

    Add 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 --autopilot
    ♻️

    Hook 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

    FlagDefaultDescription
    --config <path>./omni-rest.config.jsonPath to config file
    --frontend-dir <path>cwdFrontend project root
    --out <dir>src/ or rootOutput directory
    --models <names>allComma-separated model names
    --base-url <url>/apiAPI base URL
    --framework <name>auto-detectnextjs | vite-react | react
    --autopilotfalseSkip all prompts
    --no-bulkDisable bulk delete
    --no-optimisticDisable optimistic updates
    --no-pagesDisable Next.js page generation
    --no-menuDisable menu-data.ts
    --no-schemasSkip writing schemas.generated.ts
    --steps <mode>autoauto | always | never
    --stale-time <ms>30000TanStack Query staleTime
    --gc-time <ms>300000TanStack Query gcTime
    --helpPrint usage