Skip to main content
Install, init, and walkthrough examples live in Overview & setup. This page is the reference for initEmbeddables / initEmbeddablesServer and methods and hooks.

Set up & use Core

In JavaScript, call initEmbeddables; on the server, call initEmbeddablesServer. Both take your generated project config spread in, plus a publishableKey, and return an EmbeddablesInstance.
EmbeddablesConfig
required
The config object the Embeddables CLI generates, spread in as-is, plus your publishableKey. Treat the generated config as opaque — don’t assemble or edit it by hand.
On the server, identity comes from the cookies you pass; in the browser it comes from localStorage. The browser does not read the identity cookie at init, so a Set-Cookie on your response won’t hand the id off to the first render — it only helps later server requests. If the server mints a new id and you don’t pass it into the browser as serverAppUserId, the browser makes its own id and one visitor is counted as two.

Methods and hooks

React covers EmbeddablesProvider and the hooks. JavaScript & Server lists the shared instance methods on the object from initEmbeddables or initEmbeddablesServer, plus getCookie (server only).
Initializes Core in an effect after mount, runs each modules entry, then publishes the ready state so hooks see every registered product client. Children can render once before Core is ready — handle that loading state. config, modules, and serverAppUserId are captured on the first render only — remount with a key to change them.
EmbeddablesConfig
required
Generated project config spread in, plus publishableKey.
readonly EmbeddablesReactModule[]
Optional product SDK modules (analytics(), experiments(), forms(), …) from each SDK’s React entry point. Order matters — keep analytics before Experiments and Forms when all three are present.
string
App user id from initEmbeddablesServer during SSR so the browser does not mint a second id on first load.
EmbeddablesReactValue | null
null before init; otherwise { appUserId, isError, error } plus getAppUserId, getProjectId, getPublishableKey, and getExperiments. On failure, isError is true and appUserId is null.
string | null
The current visitor’s id, or null before Core is ready.
string | null
The project UUID, or null before init or on error.
Never throws — an invalid page key or a failing store surfaces as isError.
function
Same input as registerPageView(). Returns undefined (without error) before Core is ready or when the call failed.
function
Returns the last recorded page key, or null when none is stored or Core is not ready.
boolean
true while a page view is being recorded.
boolean
true when the latest call failed.
unknown
Details from the failed call, when isError is true.
The one place product SDKs read back the client their module registered. Most apps use each SDK’s own hook instead of calling this directly.
string
required
The module key to look up.
TClient | null
The registered client, or null before Core is ready or when no module claimed the key.

Returns

initEmbeddables and initEmbeddablesServer return an EmbeddablesInstance — the object every other SDK’s core option expects.
object
required
Exposes the read methods documented under Methods and hooks: getAppUserId, getProjectId, getPublishableKey, getExperiments, getFormIds, getFormSchema, getCookie (server), registerPageView, and getLastPageView.