Quick Start

Get Koolbase running in your app in under 5 minutes. Pick your platform to get started.

Choose your platform

1

Get your API key

Log in to your Koolbase dashboard, create a project, then create an environment. Copy the public API key:

pk_live_6e4abe2ffba691e8e44093d9

Environments

Each project has separate environments (production, staging, development). Each gets its own API key. Never use a production key in development builds.
2

Install the SDK

Add the Koolbase SDK to your pubspec.yaml:

pubspec.yaml
YAML
dependencies:
  flutter:
    sdk: flutter
  koolbase_flutter: ^1.6.0

Or install via CLI:

flutter pub add koolbase_flutter
3

Initialize the SDK

Call Koolbase.initialize() before runApp():

lib/main.dart
Dart
import 'package:flutter/material.dart';
import 'package:koolbase_flutter/koolbase_flutter.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

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

  runApp(const MyApp());
}
4

Register and login users

lib/auth_screen.dart
Dart
// Register
final user = await Koolbase.auth.register(
  email: 'user@example.com',
  password: 'securepassword',
);

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

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

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

Store and query data

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

// Query
final posts = await Koolbase.db
  .collection('posts')
  .where('published', true)
  .get();

// Update
await Koolbase.db.collection('posts').doc(id).update({
  'title': 'Updated title',
});

// Delete
await Koolbase.db.collection('posts').doc(id).delete();
6

Upload files

lib/profile_screen.dart
Dart
// Upload
await Koolbase.storage.upload(
  bucket: 'avatars',
  path: 'user_${userId}.jpg',
  file: file,
);

// Get download URL
final url = await Koolbase.storage.getDownloadUrl(
  bucket: 'avatars',
  path: 'user_${userId}.jpg',
);
7

Feature flags and remote config

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

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

What's next