Initialization
All configuration options accepted by @layers/client and @layers/react-native.
The init() call on @layers/client / @layers/react-native takes a
LayersConfig object. Source of truth: the published TypeScript
definitions in @layers/client.
Supported fields
| Field | Type | Default | Notes |
|---|---|---|---|
appId | string | required | From Project → Layers SDK. |
apiKey | string | required (by type) | Currently ignored server-side; pass any non-empty string. The X-Api-Key header is accepted but not validated. |
environment | 'development' | 'staging' | 'production' | required | Debug builds → development; release → production. All three ingest to the same prod backend; the value is persisted with each event for filtering. |
appUserId | string | undefined | — | Initial user ID; same as calling setAppUserId after init. |
enableDebug | boolean | false | Verbose console logging. |
baseUrl | string | https://in.layers.com | Override for custom domain. |
queueOptions | object | see below | Controls batching, retries, flush. |
queueStorage | QueueStorage | null | platform default | Custom queue-persistence implementation (React Native defaults to AsyncStorage; web defaults to localStorage). Pass null to disable persistence. |
queueOptions
| Field | Default | Notes |
|---|---|---|
flushIntervalMs | — | How often to flush pending events. |
maxQueueSize | — | Maximum queued events before a forced flush. |
maxItemAgeMs | — | Drop events older than this before flushing. |
requestTimeoutMs | — | Per-request timeout. |
maxRetries | — | Retry budget per batch. |
baseRetryDelayMs / maxRetryDelayMs | — | Exponential backoff bounds. |
Defaults are sane for most apps — only override if you have a specific reason.
Fields that are NOT supported today
Previous docs mentioned flushInterval (seconds), maxBatchSize,
defaultConsent, enableATT, kidsMode, testEventCode,
setSampling, name (for multi-instance). None of those are on the
LayersConfig type. They will land if / when the feature ships.
Consent
Consent is managed via setConsent({ advertising, analytics }) at
runtime, not via an init-time default. See Consent.
Remote config
After init(), the SDK fetches /config from the ingest host and
applies server-side settings (event allowlists, sampling, killswitches).
That config is cached with ETag + cache-control. You don't call
/config directly — init() handles it.