Getting Started
TypeScript SDK Getting Started
Section titled “TypeScript SDK Getting Started”Installation
Section titled “Installation”npm install @nimbleflux/fluxbase-sdk# orbun add @nimbleflux/fluxbase-sdk# oryarn add @nimbleflux/fluxbase-sdkQuick Start
Section titled “Quick Start”import { createClient } from "@nimbleflux/fluxbase-sdk";
const client = createClient( "https://your-fluxbase-instance.com", "your-api-key", // client key (publishable) or service key (secret));
// Query a tableconst { data, error } = await client .from("products") .select("id, name, price") .gte("price", 10) .order("created_at", { ascending: false }) .limit(20);
if (error) { console.error("Query failed:", error);} else { console.log("Products:", data);}Authentication
Section titled “Authentication”Sign Up / Sign In
Section titled “Sign Up / Sign In”// Create a new userconst { data: signUpData, error: signUpError } = await client.auth.signUp({ email: "user@example.com", password: "secure-password",});
// Sign inconst { session, error } = await client.auth.signIn({ email: "user@example.com", password: "secure-password",});
// Session is automatically stored and sent with subsequent requests// Get OAuth URL for Googleconst { data, error } = await client.auth.getOAuthUrl({ provider: "google", redirectUrl: "http://localhost:3000/callback",});
window.location.href = data.url;Data Operations
Section titled “Data Operations”Insert
Section titled “Insert”const { data, error } = await client .from("products") .insert({ name: "Widget", price: 29.99 }) .select();Update
Section titled “Update”const { data, error } = await client .from("products") .update({ price: 24.99 }) .eq("id", productId) .select();Delete
Section titled “Delete”const { error } = await client .from("products") .delete() .eq("id", productId);Realtime
Section titled “Realtime”const channel = client .realtime .channel("products-changes") .on("postgres_changes", { table: "products" }, (payload) => { console.log("Change:", payload); }) .subscribe();Storage
Section titled “Storage”// Upload a fileconst { error } = await client.storage .from("documents") .upload("report.pdf", fileBlob);
// Download a fileconst { data, error } = await client.storage .from("documents") .download("report.pdf");Error Handling
Section titled “Error Handling”All SDK methods return a { data, error } result type. Check for errors explicitly:
const { data, error } = await client.from("users").select("*");
if (error) { // Handle error — error is always an Error object with status/code console.error(error.message); return;}
// Use data — TypeScript knows it's defined hereconsole.log(data);Next Steps
Section titled “Next Steps”- Advanced Features — Aggregations, vector search, batch operations
- Admin SDK — Admin operations (users, client keys, webhooks)
- Management SDK — Client keys, webhooks, invitations
- Settings SDK — App and system settings
- DDL SDK — Schema and table management