Back-end for Next.js (beta)
import { , , } from 'vovk';
import { } from 'zod';
import from './UserService';
@('users')
export default class {
@('{id}')
static = ({
: .({ : .() }),
: .({ : .() }),
: .({ : .(['push', 'sms']) }),
async (, { }) {
const = await .();
const const notify: "push" | "sms"notify = ...('notify');
return .(, , );
},
});
}import { } from 'vovk-client';
/**
* Runs regular fetch under the hood, e.g.:
* fetch('/api/users/.../?notify=push', { method: 'PUT', body })
* UserRPC.updateUser type is directly inferred
* from UserController.updateUser
*/
const = await .({
: {
: 'a3bb189e-8bf9-3888-9912-ace4e6543002',
},
: {
: 'push',
},
: {
: 'john.doe@example.com',
},
// options defined in a custom fetcher
: 'User updated successfully',
: 'Failed to update user',
});Features
Vovk.ts combines TypeScript inference with code generation to achieve contract-less RPC over RESTful API with type mapping between controllers and RPC modules.
On the back-end it wraps Next.js Route Handlers to provide service-controller architecture layer, decorator-style syntax, request validation, additional type safety for NextRequest object, and OpenAPI spec generation.
Controllers and generated RPC modules can be used as LLM function calling tools for AI SDK, MCP, or any other AI instruments. The first one for current context execution, the second one for calling back-end API methods via HTTP requests.
The RPC client can be bundled and published to NPM with ready-to-use package.json and README.md that describes all available methods as code examples.