JavaScript & TypeScript SDK
Official client library for querying data, invoking serverless functions, and managing authentication.
Installation & Package Setup
The Rayvotech Client SDK is available on npm and can be installed via your favorite package manager or included via CDN script tag:
npm install @rayvotech/sdk
# Or using yarn: yarn add @rayvotech/sdk
# Or using pnpm: pnpm add @rayvotech/sdk
# Or using yarn: yarn add @rayvotech/sdk
# Or using pnpm: pnpm add @rayvotech/sdk
Initializing the Client
Import and instantiate the client using your project workspace token and edge endpoint URL:
import { createRayvotechClient } from '@rayvotech/sdk';
const rayvotech = createRayvotechClient({
projectId: 'proj_live_948274921',
apiKey: process.env.RAYVOTECH_PUBLIC_KEY,
edgeUrl: 'https://edge.rayvotech.tools'
});
const rayvotech = createRayvotechClient({
projectId: 'proj_live_948274921',
apiKey: process.env.RAYVOTECH_PUBLIC_KEY,
edgeUrl: 'https://edge.rayvotech.tools'
});
Type-Safe CRUD Operations & Real-time Listeners
Execute type-safe database queries with full TypeScript autocompletion and reactive live listeners:
// Fetch filtered records with pagination
const { data, error } = await rayvotech
.from('subscriptions')
.select('id, user_id, plan, status, next_invoice')
.where('status', '==', 'active')
.orderBy('created_at', 'desc')
.limit(20);
// Subscribe to real-time database updates
rayvotech.from('deals').on('UPDATE', (payload) => {
console.log('Deal updated in real time:', payload.new);
});
const { data, error } = await rayvotech
.from('subscriptions')
.select('id, user_id, plan, status, next_invoice')
.where('status', '==', 'active')
.orderBy('created_at', 'desc')
.limit(20);
// Subscribe to real-time database updates
rayvotech.from('deals').on('UPDATE', (payload) => {
console.log('Deal updated in real time:', payload.new);
});