React Native SDK

Use Koolbase in your React Native app — auth, database, storage, realtime, feature flags, and functions in one TypeScript package.

Installation

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

Setup

Initialize the SDK once at app startup — before any screens render.

App.tsxTypeScript
import { Koolbase } from 'koolbase-react-native';

export default function App() {
  useEffect(() => {
    Koolbase.initialize({
      publicKey: 'pk_live_your_key_here',
      baseUrl: 'https://api.koolbase.com',
    });
  }, []);

  return <Navigation />;
}

Get your public key

Log in to app.koolbase.com, open your project, go to Environments, and copy the public SDK key.

Authentication

screens/AuthScreen.tsxTypeScript
import { Koolbase } from 'koolbase-react-native';

// Register
const user = await Koolbase.auth.register({
  email: 'user@example.com',
  password: 'securepassword',
});

// Login
const session = await Koolbase.auth.login({
  email: 'user@example.com',
  password: 'securepassword',
});

// Current user
const me = Koolbase.auth.currentUser;

// Logout
await Koolbase.auth.logout();

// Password reset
await Koolbase.auth.forgotPassword('user@example.com');

Database

screens/PostsScreen.tsxTypeScript
import { Koolbase } from 'koolbase-react-native';

// Insert
await Koolbase.db.insert('posts', {
  title: 'Hello Koolbase',
  published: true,
});

// Query
const { records, total } = await Koolbase.db.query('posts', {
  filters: { published: true },
  limit: 10,
  orderBy: 'created_at',
  orderDesc: true,
});

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

// Get single record
const post = await Koolbase.db.get('record-id');

// Update
await Koolbase.db.update('record-id', { title: 'Updated' });

// Delete
await Koolbase.db.delete('record-id');

Storage

screens/ProfileScreen.tsxTypeScript
import { Koolbase } from 'koolbase-react-native';
import { launchImageLibrary } from 'react-native-image-picker';

// Upload
const { url } = await Koolbase.storage.upload({
  bucket: 'avatars',
  path: `user-${userId}.jpg`,
  file: {
    uri: imageResult.assets[0].uri,
    name: 'avatar.jpg',
    type: 'image/jpeg',
  },
});

// Get download URL
const downloadUrl = await Koolbase.storage.getDownloadUrl(
  'avatars',
  `user-${userId}.jpg`
);

// Delete
await Koolbase.storage.delete('avatars', `user-${userId}.jpg`);

Realtime

screens/FeedScreen.tsxTypeScript
import { Koolbase } from 'koolbase-react-native';

useEffect(() => {
  const unsubscribe = Koolbase.realtime.subscribe('messages', (event) => {
    if (event.type === 'created') {
      setMessages(prev => [event.record, ...prev]);
    }
    if (event.type === 'deleted') {
      setMessages(prev => prev.filter(m => m.id !== event.record.id));
    }
  });

  return () => unsubscribe();
}, []);

Feature flags & remote config

screens/HomeScreen.tsxTypeScript
import { Koolbase } from 'koolbase-react-native';

// Feature flag
if (Koolbase.isEnabled('new_checkout')) {
  // show new checkout UI
}

// Remote config
const timeout = Koolbase.configNumber('timeout_seconds', 30);
const apiUrl = Koolbase.configString('api_url', 'https://api.myapp.com');
const darkMode = Koolbase.configBool('force_dark_mode', false);

// Version check
const result = Koolbase.checkVersion('1.2.3');
if (result.status === 'force_update') {
  // block the app and show update screen
}

Functions

screens/CheckoutScreen.tsxTypeScript
import { Koolbase } from 'koolbase-react-native';

const result = await Koolbase.functions.invoke('process-payment', {
  amount: 4999,
  currency: 'USD',
  userId: user.id,
});

if (result.success) {
  console.log(result.data);
}

Source & contributing

The React Native SDK is open source at github.com/kennedyowusu/koolbase-react-native. Issues and PRs welcome.