@vocoweb/sdk
v1.1.0
Published
The Operating System for SaaS - Unified VocoWeb SDK
Maintainers
Readme
@vocoweb/sdk
The Operating System for SaaS
The unified VocoWeb SDK that consolidates all core modules into a single package for maximum developer productivity.
Installation
npm install @vocoweb/sdkEnvironment Variables
NEXT_PUBLIC_VOCO_URL=https://your-app.vocoweb.in
VOCO_API_KEY=voco_sk_...
NEXT_PUBLIC_SUPABASE_URL=https://xxx.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJ...
SUPABASE_SERVICE_ROLE_KEY=eyJ...
NEXT_PUBLIC_STRIPE_KEY=pk_live_...Quick Start
1. Wrap Your App
// app/layout.tsx
import { VocoProvider } from '@vocoweb/sdk/react';
export default function RootLayout({ children }) {
return (
<html>
<body>
<VocoProvider>{children}</VocoProvider>
</body>
</html>
);
}2. Add Middleware
// middleware.ts
import { vocoMiddleware } from '@vocoweb/sdk/middleware';
export default vocoMiddleware;
export const config = {
matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],
};3. Use the SDK
import { useVocoAuth, useVocoTenant, VocoGate } from '@vocoweb/sdk/react';
import { voco } from '@vocoweb/sdk/server';
// Client-side
function Dashboard() {
const { user, logout } = useVocoAuth();
const { currentOrg } = useVocoTenant();
return (
<VocoGate feature="analytics">
<AnalyticsDashboard />
</VocoGate>
);
}
// Server-side (with automatic tenant isolation)
async function getData() {
const data = await voco.db.from('projects').select('*');
return data; // Automatically filtered by tenant_id
}Included Modules
Core Modules
| Module | Purpose |
|--------|---------|
| @vocoweb/kernel | Auth, Billing, Legal, Compliance |
| @vocoweb/tenant | Multi-tenancy & RBAC |
| @vocoweb/features | Feature gating & Entitlements |
| @vocoweb/meter | Usage tracking & Limits |
| @vocoweb/notify | Notifications (email, in-app, push) |
| @vocoweb/admin | Super admin panel |
Security & Compliance
| Module | Purpose |
|--------|---------|
| @vocoweb/a11y-guard | WCAG 2.1 AA accessibility with ESLint plugin |
| @vocoweb/erasure | GDPR Right to be Forgotten with retention engine |
| @vocoweb/portability | GDPR Data Portability with schema discovery |
| @vocoweb/residency | Schrems II data sovereignty with Cloudflare Workers |
| @vocoweb/consent | GDPR cookie consent with GeoIP detection |
| @vocoweb/invoice | EU VAT invoice generator with PDF rendering |
Developer Experience
| Module | Purpose |
|--------|---------|
| @vocoweb/codegen | TypeScript schema generator with watch mode |
| @vocoweb/local | Offline development with SQLite adapter |
| @vocoweb/errors | Error dictionary with i18n support |
Growth
| Module | Purpose |
|--------|---------|
| @vocoweb/viral | Referral system with fraud detection |
Components
Identity
<VocoSignIn />- Complete login card<VocoUserButton />- Avatar dropdown
Tenant
<VocoOrgSwitcher />- Team switcher<VocoInviteForm />- Member invite form
Billing
<VocoPricingTable />- Stripe pricing columns<VocoBillingPortalButton />- Stripe portal button
Compliance
<VocoFooterLinks />- Privacy, Terms, DPA links<VocoGate />- Feature gate wrapper
Hooks
useVocoAuth() // { user, login, logout, isLoading }
useVocoTenant() // { currentOrg, switchOrg, members }
useVocoGate(f) // { isEnabled, upgradeUrl }
useVocoNotify() // { notifications, markRead }Server API
import { voco } from '@vocoweb/sdk/server';
// Safe database (auto tenant isolation)
await voco.db.from('table').select('*');
// Auth
await voco.auth.requireUser(request);
// Features
await voco.features.requireFeature(userId, 'analytics');
// Meter
await voco.meter.checkLimit(userId, 'api_calls');License
MIT © VocoWeb
