@nextvm/runtime-client
Mirror of @nextvm/runtime-server for the client side. Importing this package gives you a single function — bootstrapClient — that wires the ModuleLoader, the typed RPC transport, and FiveM client events into one start function.
Install
bash
pnpm add @nextvm/runtime-clientMinimal usage
typescript
// modules/my-server/src/client/index.ts
import { bootstrapClient } from '@nextvm/runtime-client'
import banking from '@nextvm/banking'
import jobs from '@nextvm/jobs'
await bootstrapClient({
modules: [banking, jobs],
})The runtime:
- Registers every passed module with the
ModuleLoader - Auto-wires a
RuntimeRpcTransportagainst the FiveM client globals - Calls
loader.initialize('client')so each module'sclient()entry runs andonModuleInit/onModuleReadyhooks fire - Bridges FiveM client events:
playerSpawned→onMounted(the "framework is ready, the local player ped exists" hookonClientResourceStop→onModuleStop
- Starts the managed tick loop via
setTick
RPC transport wire protocol
client → server: emitNet('__nextvm:rpc', namespace, procedure, input, requestId)
server → client: emitNet('__nextvm:rpc:response', requestId, errorMessage|null, result|null)The transport keeps a Map<requestId, { resolve, reject }> and resolves the matching entry when the response event fires. Unknown ids are dropped silently. Each call has a 10s default timeout (configurable via RuntimeRpcTransport({ timeoutMs })).
Using a typed RPC client
typescript
import { createClient } from '@nextvm/core'
import { bootstrapClient } from '@nextvm/runtime-client'
import type { bankingRouter } from '@nextvm/banking'
const runtime = await bootstrapClient({ modules: [/* ... */] })
const banking = createClient<typeof bankingRouter>('banking', runtime.transport.call)
const balance = await banking.getMyBalance()API
bootstrapClient(opts): Promise<ClientRuntimeHandle>
| Option | Required | Description |
|---|---|---|
modules | yes | Module definitions to register |
transport | no | Inject a custom transport (tests use this) |
ClientRuntimeHandle
| Method | Purpose |
|---|---|
loader | The underlying ModuleLoader |
transport | The RuntimeRpcTransport instance |
runFrame(now?) | Run a single tick frame (test helper) |
handleMounted() | Trigger the onMounted flow |
stop() | Graceful shutdown |
See also
@nextvm/runtime-server— server side@nextvm/core—createClienttyped proxy- 2