Reference
API reference map
A compact map of the public imports and what each one is for.
Use this when: Use this page when you need the exact import after reading the tutorial pages.
Server
Contract helpers
Import server helpers only from server-side files such as .socket.ts and hooks.socket.ts.
import {
// Define the realtime contract for one route folder.
socket,
// Define browser-to-server handlers and server-to-browser ack events.
event,
// Define private rooms and validated join requests.
room,
// Create socket locals from cookies or request data.
handleSocket,
// Read details about the current socket event from helper code.
getSocketEvent,
// Return controlled realtime failures.
RealtimeError
} from 'liverpc/server';Verify: No browser bundle should include liverpc/server or $lib/server imports.
Client
Generated clients and refresh helpers
Browser pages import sibling .socket.ts exports directly. The Vite plugin replaces those imports with generated browser clients.
import { refreshRealtime, RealtimeError } from 'liverpc/client';
// In +page.svelte, this import becomes generated browser code.
import { chat } from './chat.socket';
// Create a lazy typed channel.
const room = chat();Verify: Call room.connect(), room.on.message(), or room.emit.send() and confirm the Socket.IO connection opens only when the page uses it.
Integration
Vite, adapter, and custom Node server
Most apps use the Vite plugin plus adapter wrapper. Advanced Node servers can attach the realtime layer manually.
import { realtime } from 'liverpc/vite';
import adapter from 'liverpc/adapter-node';
// Advanced Node server integration.
import { attachRealtimeServer } from 'liverpc/node';Verify: Run a production build after any adapter change; unsupported adapters should fail before deploy.