CLI

CLI

vovk dev

The command runs Vovk Server expecting to be run together with Next.js dev server. It uses PORT variable to define its own port by adding 6969 to it. For example, if Next.js server runs on port 3000, Vovk Server will run on port 9969.

It's recommended to use vovk dev and next dev together with concurrently (opens in a new tab) or similar library. Here is an example of how to run them simultaneously:

PORT=3000 npx concurrently 'vovk dev' 'next dev' --kill-others

Since both Vovk Server and Next.js know the port of each other they can communicate in order to build .vovk.json and node_modules/.vovk files.

vovk dev --next-dev

You can avoid using concurrently by running vovk dev with --next-dev flag. This command runs next dev by itself and assigns the port automatically.

⚠️

The built-in commands runner works fine, but is not tested as good as concurrently. Use it at your own risk.

vovk generate

Generates the client based on .vovk.json and creates .js and .d.ts files at node_modules/.vovk that are re-exported by vovk-client. .vovk.json is generated via vovk dev.

vovk generate as well as vovk dev accept --clientOut flag that indicates where client needs to be generated.

npx vovk generate --clientOut=my-custom-folder

All other commands such as next build and next start remain the same since the project is a normal Next.js application.

Available env variables

Environment variables allow to customize Vovk.ts behaviour by overriding configuration optionally defined at vovk.config.js. You can find more information about it at vovk.config.js documentation. Here is a quick ref:

  • PORT=3000 - defines port for Next.js server that is also utilised by the Vovk Server.
  • VOVK_PORT=3690 - a custom Vovk Server port.
  • VOVK_CLIENT_OUT=./node_modules/.vovk - where the client needs to be compiled to.
  • VOVK_ROUTE=./src/app/api/[[...vovk]]/route.ts - allows to redefine path to the wildcard route.
  • VOVK_MODULES_DIR=./src/modules - defines the root directory where the modules are located.
  • VOVK_FETCHER=vovk/client/defaultFetcher - allows to customize the fetching function that used internally by the client.
  • VOVK_PREFIX=/api - defines the root endpoint used by fetch function at the client.
  • VOVK_VALIDATE_ON_CLIENT - defines client-side validation library. If vovk-zod (opens in a new tab) is installed but VOVK_VALIDATE_ON_CLIENT is not redefined it's value going to be set to "vovk-zod/zodValidateOnClient".