Configuration
Most FFDB apps only need one required value: apiUrl. Everything else in createClient configuration can stay at defaults until your app needs stricter runtime control.
Minimum config
import { createClient } from 'ffdb-client'
const client = await createClient({
config: {
apiUrl: import.meta.env.VITE_FFDB_API_URL,
},
})
Core config fields
- Name
apiUrl- Type
- string
- Description
Base URL for your FFDB app. This is the key value most applications provide.
- Name
origin- Type
- string
- Description
Optional app origin. Usually inferred in browsers; set it explicitly in Node.js and non-browser runtimes.
- Name
retryAttempts- Type
- number
- Description
Number of retry attempts for failed requests.
- Name
healthProbeIntervalMs- Type
- number
- Description
Probe interval used while recovering connectivity. Set to
0to disable probes.
- Name
logEnabled- Type
- boolean
- Description
Enables SDK logging for troubleshooting.
- Name
logLevel- Type
- info | verbose
- Description
Controls logging detail when logging is enabled.
Avoid placing privileged credentials in browser-visible config. Keep admin-level values in trusted environments only.
Environment variable patterns
Use runtime-appropriate env keys in app code:
- Name
VITE_FFDB_API_URL- Description
Vite apps.
- Name
NEXT_PUBLIC_FFDB_API_URL- Description
Next.js browser code.
- Name
EXPO_PUBLIC_FFDB_API_URL- Description
Expo / React Native apps.
Node.js config loading
Use the Node entrypoint when you want env-based configuration in server scripts or services:
import { createClient, createNodeLifecycle, loadEnvConfig } from 'ffdb-client/node'
import type { Database } from './ffdb.types'
const config = loadEnvConfig()
const { db, destroy } = await createClient<Database>({
config,
lifecycle: createNodeLifecycle(),
})
await destroy()
Typical Node env variables include API_URL, ORIGIN, FFDB_AUTH_TOKEN, FFDB_API_KEY, RETRY_ATTEMPTS, and logging flags.
Recommended defaults strategy
- Start with only
apiUrl. - Add
originfor Node or service contexts. - Enable retries/logging only when needed.
- Keep credentials in environment variables, not source files.