@fluxbase/sdk
v2026.3.5
Published
Official TypeScript SDK for Fluxbase - Backend as a Service
Maintainers
Readme
@fluxbase/sdk
Official TypeScript/JavaScript SDK for Fluxbase - Backend as a Service.
Features
- Type-safe - Full TypeScript support with generated types
- Database Queries - PostgREST-compatible query builder with filters, ordering, pagination
- Aggregations - Count, sum, avg, min, max with GROUP BY support
- Batch Operations - Efficient multi-row insert, update, delete
- Authentication - JWT-based auth with automatic token refresh
- Realtime - WebSocket subscriptions to database changes
- Storage - File upload/download with S3 compatibility
- RPC - Call PostgreSQL functions directly
- Lightweight - Zero dependencies except fetch polyfill
Installation
npm install @fluxbase/sdk
# or
yarn add @fluxbase/sdk
# or
pnpm add @fluxbase/sdkQuick Start
import { createClient } from "@fluxbase/sdk";
// Create a client
const client = createClient({
url: "http://localhost:8080",
auth: {
autoRefresh: true,
persist: true,
},
});
// Authentication
await client.auth.signUp({
email: "[email protected]",
password: "secure-password",
});
// Query data
const { data } = await client
.from("products")
.select("*")
.eq("category", "electronics")
.gte("price", 100)
.execute();
// Aggregations
const stats = await client
.from("products")
.count("*")
.groupBy("category")
.execute();
// Realtime subscriptions
client.realtime
.channel("table:public.products")
.on("INSERT", (payload) => console.log("New:", payload.new_record))
.subscribe();
// File upload
await client.storage.from("avatars").upload("user-123.png", file);Documentation
Core Guides
- Getting Started - Installation, configuration, and basic usage
- Database Operations - Queries, filters, aggregations, batch operations, and RPC
- React Hooks - React integration with
@fluxbase/sdk-react
API Reference
- TypeScript API Docs - Auto-generated from source code
Browser & Node.js Support
- Browsers: All modern browsers with ES6+ and Fetch API
- Node.js: v18+ (native fetch) or v16+ with
cross-fetchpolyfill
TypeScript Support
Fully typed with TypeScript. Define your schemas for complete type safety:
interface Product {
id: number;
name: string;
price: number;
category: string;
}
const { data } = await client.from<Product>("products").select("*").execute();
// data is typed as Product[]Examples
Check out working examples in the /example directory:
- Vanilla JavaScript/TypeScript
- React with hooks
- Next.js integration
- Vue 3 integration
React Integration
For React applications, use @fluxbase/sdk-react for hooks and automatic state management:
# npm
npm install @fluxbase/sdk @fluxbase/sdk-react @tanstack/react-query
# pnpm
pnpm add @fluxbase/sdk @fluxbase/sdk-react @tanstack/react-querySee the React Hooks Guide for details.
Contributing
Contributions are welcome! Please read our Contributing Guide for details.
License
MIT © Fluxbase
