Dart SDK - Installation#
rafikidb is a typed client for the RafikiDB API: data, auth, realtime,
storage, environment variables, secrets, webhooks, edge functions and
payments.
- Pure Dart - works in Flutter, Dart servers and CLI apps
- Typed
Envelope<T>responses andRafikiDBErrorfailures - WebSocket (Centrifugo) + SSE realtime with auto-reconnect
- Pluggable session persistence (
FileSessionStoreor your own)
Install#
dart pub add rafikidb
# or, in a Flutter app
flutter pub add rafikidb
BashInitialize#
import 'package:rafikidb/rafikidb.dart';
final db = RafikiDB(
projectId: '5c73dab0-...',
apiKey: 'raf_live_...',
baseUrl: 'https://api.rafikidb.com/api/v1', // optional
persistSession: true, // optional: survive restarts
);
DART| Option | Type | Description |
|---|---|---|
projectId | String | Required. Used by auth/realtime URLs |
apiKey | String | Required. Sent as X-AFRIBASE-API-Key |
baseUrl | String | Default http://localhost:8080/api/v1 |
accessToken | String? | Optional platform JWT |
persistSession | bool | Persist the project-user session (file store by default) |
sessionStore | SessionStore? | Custom persistence backend (e.g. shared_preferences) |
httpClient | http.Client? | Custom HTTP client |
Responses#
Every method returns the API envelope unchanged:
final rows = await db.from('profiles').select('id').limit(10).execute();
rows.success; // true
rows.message; // "Request was successful"
rows.data; // List<Map<String, dynamic>>?
rows.errors; // List<String>?
DARTFailures throw RafikiDBError:
try {
await db.from('profiles').insert({});
} on RafikiDBError catch (error) {
error.message; // "Nationality is required"
error.status; // 400
error.code; // RafikiDBErrorCode.invalidInput
error.errors; // ["Nationality is required"]
}
DARTNext: Data.