Layers

Initialization

All configuration options accepted by @layers/client and @layers/react-native.

View as Markdown

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

FieldTypeDefaultNotes
appIdstringrequiredFrom Project → Layers SDK.
apiKeystringrequired (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'requiredDebug builds → development; release → production. All three ingest to the same prod backend; the value is persisted with each event for filtering.
appUserIdstring | undefinedInitial user ID; same as calling setAppUserId after init.
enableDebugbooleanfalseVerbose console logging.
baseUrlstringhttps://in.layers.comOverride for custom domain.
queueOptionsobjectsee belowControls batching, retries, flush.
queueStorageQueueStorage | nullplatform defaultCustom queue-persistence implementation (React Native defaults to AsyncStorage; web defaults to localStorage). Pass null to disable persistence.

queueOptions

FieldDefaultNotes
flushIntervalMsHow often to flush pending events.
maxQueueSizeMaximum queued events before a forced flush.
maxItemAgeMsDrop events older than this before flushing.
requestTimeoutMsPer-request timeout.
maxRetriesRetry budget per batch.
baseRetryDelayMs / maxRetryDelayMsExponential 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 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.

On this page