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 0 to 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.

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.

  1. Start with only apiUrl.
  2. Add origin for Node or service contexts.
  3. Enable retries/logging only when needed.
  4. Keep credentials in environment variables, not source files.

Next pages

  1. Authentication
  2. Database queries
  3. Access control

Was this page helpful?