Quick Start
vRPC is designed to get you from an OpenAPI spec to a type-safe client in under 60 seconds.
1. Installation
Install vrpc as a development dependency.
bash
pnpm add -D vrpc2. Initialization
Run the automated setup wizard. This will scaffold your configuration, a custom mutator, and your client entry point.
bash
pnpm vrpc initThe wizard will create:
vrpc.yaml: Your project configuration.src/vrpc/: A directory containing your regeneratable protocol and your editable client files.
3. Generate the Types
Pull the latest specs and regenerate the type-safe procedures:
bash
pnpm vrpc generate4. Basic Usage
By default, vRPC scaffolds a Minimalist client. You can start making requests immediately:
typescript
import { api } from './vrpc/rpc.client'
// 1. Make a request
const response = await api.getUser({
params: { id: '42' },
})
// 2. Narrow by status (100% Type-Safe)
if (response.status === 200) {
// response.data is automatically typed as 'User'
console.log(response.data.name)
}5. Enable Zero-Runtime
To optimize your bundle for production, add the vRPC plugin to your bundler. For Vite:
typescript
// vite.config.ts
import { vitePlugin as vRPC } from 'vrpc/plugins'
export default {
plugins: [vRPC()],
}What's Next?
- Learn how to Customize your Mutator (Axios, Ky, etc.).
- Explore Multi-Spec Support for complex architectures.
- Check out the CLI Reference for advanced commands.