Skip to Content
vovk dev

vovk dev

Quick CLI Ref
$ npx vovk@draft dev --help Usage: vovk dev|d [options] [nextArgs...] Start schema watcher (optional flag --next-dev to start it with Next.js) Arguments: nextArgs extra arguments for the implicit next dev command call Options: --next-dev start schema watcher and Next.js with automatic port allocation --exit kill the processes when schema and client are generated --schema-out <path> path to schema output directory (default: .vovk-schema) --https, --dev-https use HTTPS for the dev server (default: false) -h, --help display help for command

The vovk dev command runs a watcher that monitors controllers and updates the schema and client as needed. It does this by issuing HTTP GET requests to /api/<segment-name>/_schema_, where <segment-name> is the relevant segment. If the schema has changed, the watcher updates the JSON files and regenerates the client modules.

How It Works

  1. vovk dev and next dev run together via concurrently .
  2. vovk dev watches the /src/modules directory (configurable with modulesDir).
  3. On change, the script checks whether the file contains a controller and belongs to a segment using simple RegExp checks.
  4. If it is a controller within a segment, the script requests /api/<segment-name>/_schema_ to retrieve the updated schema.
  5. If the schema differs:
    • If the controller list has changed (added, removed, renamed) or method definitions (including validation) were updated, the script writes the schema to the .vovk-schema directory as <segment-name>.json.
    • If the controller list changed, the client is also regenerated. The client imports schema JSON files to initialize the exported library. By default, the composed client is generated in node_modules/.vovk-client and re-exported by vovk-client. When the segmented client is enabled, files are generated to the source directory (default: ./src/client).
vovk dev

Because vovk dev is typically used alongside the Next.js dev server, there are two ways to run it, both using concurrently :

  1. Explicit way: Preferable if you want minimal abstraction. The downside is that you must set PORT explicitly:
PORT=3000 npx concurrently 'vovk dev' 'next dev' --kill-others

You can pass Next.js flags as usual:

PORT=3000 npx concurrently 'vovk dev --https' 'next dev --experimental-https --turbo' --kill-others
  1. Implicit way: Ports are assigned automatically. The script checks whether port 3000 (by default) is in use and selects the next available port:
npx vovk dev --next-dev

To pass flags to next dev, append them after --:

npx vovk dev --https --next-dev -- --experimental-https --turbo

Internally, the implicit mode uses the concurrently API, making both approaches nearly identical.

Read more about HTTPS in development.

When you run vovk init, the dev script in package.json is updated while preserving your previous value and flags:

{ "scripts": { // was // "dev": "next dev --experimental-https --turbo", // becomes "dev": "vovk dev --next-dev -- --experimental-https --turbo" } }

Run and Exit

Use the --exit flag to terminate the processes started by vovk dev after the schema and client are generated. This is useful for one-off runs without keeping the watcher active.

npx vovk dev --next-dev --exit

For convenience, add a dedicated script in package.json:

{ "scripts": { // ... "dev-exit": "vovk dev --next-dev --exit", // or "dev-exit": "PORT=3000 concurrently 'vovk dev --exit' 'next dev' --kill-others" } }
Last updated on