Skip to content

kennedyowusu/koolbase-react-native

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

koolbase-react-native

React Native SDK for Koolbase — auth, database, storage, realtime, feature flags, and functions in one package.

Installation

npm install koolbase-react-native
# or
yarn add koolbase-react-native

Setup

import { Koolbase } from 'koolbase-react-native';

await Koolbase.initialize({
  publicKey: 'pk_live_your_key_here',
  baseUrl: 'https://api.koolbase.com',
});

Auth

await Koolbase.auth.register({ email: 'user@example.com', password: 'password' });
await Koolbase.auth.login({ email: 'user@example.com', password: 'password' });
const user = Koolbase.auth.currentUser;
await Koolbase.auth.logout();

Database

await Koolbase.db.insert('posts', { title: 'Hello', published: true });
const { records } = await Koolbase.db.query('posts', { filters: { published: true }, limit: 10 });
await Koolbase.db.update('record-id', { title: 'Updated' });
await Koolbase.db.delete('record-id');

// Populate related records
const { records } = await Koolbase.db.query('posts', {
  populate: ['author_id:users'],
});

Storage

const { url } = await Koolbase.storage.upload({
  bucket: 'avatars',
  path: 'user-123.jpg',
  file: { uri: fileUri, name: 'avatar.jpg', type: 'image/jpeg' },
});

Feature Flags

if (Koolbase.isEnabled('new_checkout')) {
  // show new checkout
}
const timeout = Koolbase.configNumber('timeout_seconds', 30);

Functions

const result = await Koolbase.functions.invoke('send-email', {
  email: 'user@example.com',
});

Documentation

Full docs at docs.koolbase.com

License

MIT

Offline-First Database

Koolbase v1.1.0 ships with offline-first support powered by AsyncStorage.

// Cache-first reads — returns local data instantly
const { records, isFromCache } = await Koolbase.db.query('posts', {
  filters: { published: true },
  limit: 20,
});

if (isFromCache) {
  console.log('Served from local cache');
}

// Optimistic writes — saved locally first, synced when online
await Koolbase.db.insert('posts', { title: 'Hello', published: true });

// Manual sync
await Koolbase.db.syncPendingWrites();

The SDK automatically syncs pending writes when network connectivity is restored.

Functions

import { Koolbase, FunctionRuntime } from 'koolbase-react-native';

// Deploy a TypeScript function (Deno)
await Koolbase.functions.deploy({
  name: 'send-email',
  code: `
    export async function handler(ctx) {
      return { ok: true };
    }
  `,
  runtime: FunctionRuntime.Deno,
});

// Deploy a Dart function
await Koolbase.functions.deploy({
  name: 'process-order',
  code: dartCode,
  runtime: FunctionRuntime.Dart,
});

// Invoke a function
const result = await Koolbase.functions.invoke('send-email', {
  to: 'user@example.com',
});

About

React Native SDK for Koolbase — auth, database, storage, realtime, feature flags, and functions for mobile apps.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors