Github|...

Configuration

The SyncedDbConfig (or SpookyConfig) object allows you to customize the behavior of the Spooky client.

Configuration Interface

TypeScript
interface SyncedDbConfig<Schema> {
/** The runtime schema generated by the CLI */
schema: Schema;

/** The raw SURQL schema string (also generated) */
schemaSurql: string;

/** Logging verbosity level */
logLevel: 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';

/** Database connection configuration */
database: {
  /** The SurrealDB endpoint URL */
  endpoint?: string;
  
  /** The namespace to use */
  namespace: string;
  
  /** The database name */
  database: string;
  
  /** The local store type implementation */
  store?: 'memory' | 'indexeddb';
  
  /** Authentication token (optional) */
  token?: string;
};

/** Unique client identifier (auto-generated if not provided) */
clientId?: string;

/** Persistence client: 'surrealdb' (default), 'localstorage', or custom */
persistenceClient?: 'surrealdb' | 'localstorage' | PersistenceClient;

/** OpenTelemetry collector endpoint for telemetry data */
otelEndpoint?: string;

/** Debounce time in milliseconds for stream updates (default: 100ms) */
streamDebounceTime?: number;
}

Example Configuration

TypeScript
import { SyncedDb, type SyncedDbConfig } from '@spooky-sync/client-solid';
import { schema, SURQL_SCHEMA } from './schema.gen';

const dbConfig: SyncedDbConfig<typeof schema> = {
logLevel: 'info',
schema: schema,
schemaSurql: SURQL_SCHEMA,
database: {
  namespace: 'main',
  database: 'main',
  endpoint: 'ws://localhost:8000/rpc',
  store: 'indexeddb', // or 'memory' for transient storage
},
// Optional: custom client ID
clientId: 'my-app-client',
// Optional: OpenTelemetry endpoint
otelEndpoint: '/v1/logs',
};

export const db = new SyncedDb<typeof schema>(dbConfig);

Options Detail

database.endpoint

The WebSocket URL for your SurrealDB instance (e.g., ws://localhost:8000/rpc). The Spooky client connects directly to the database.

database.store

  • 'indexeddb' (default): Persistent local storage in the browser
  • 'memory': Transient in-memory storage (clears on page reload)

logLevel

Controls the verbosity of logging output:

  • 'trace': Most verbose, includes all internal operations
  • 'debug': Detailed debugging information
  • 'info': General lifecycle events (connected, synced)
  • 'warn': Recoverable errors and warnings
  • 'error': Critical failures
  • 'fatal': Fatal errors that stop execution

persistenceClient

Determines where metadata like query states are persisted:

  • 'surrealdb' (default): Store in the local SurrealDB instance
  • 'localstorage': Use browser localStorage
  • Custom implementation of PersistenceClient interface