initEmbeddables / initEmbeddablesServer and methods and hooks.
Set up & use Core
In JavaScript, callinitEmbeddables; on the server, call initEmbeddablesServer. Both take your generated project config spread in, plus a publishableKey, and return an EmbeddablesInstance.
- JavaScript
- Server
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.Methods and hooks
React coversEmbeddablesProvider and the hooks. JavaScript & Server lists the shared instance
methods on the object from initEmbeddables or initEmbeddablesServer, plus
getCookie (server only).
- React
- JavaScript & Server
EmbeddablesProvider
Root wrapper — not a hook
EmbeddablesProvider
Root wrapper — not a hook
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.useEmbeddables()
The enriched Core instance, or null before ready
useEmbeddables()
The enriched Core instance, or null before ready
EmbeddablesReactValue | null
null before init; otherwise { appUserId, isError, error } plus getAppUserId, getProjectId,
getPublishableKey, and getExperiments. On failure, isError is true and appUserId is
null.useAppUserId()
Just the visitor id
useAppUserId()
Just the visitor id
string | null
The current visitor’s id, or
null before Core is ready.useEmbeddablesProjectId()
Just the project UUID
useEmbeddablesProjectId()
Just the project UUID
string | null
The project UUID, or
null before init or on error.useRegisterPageView()
Record page views from React
useRegisterPageView()
Record page views from React
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.useEmbeddablesModule({ key })
Read a registered product client (advanced)
useEmbeddablesModule({ key })
Read a registered product client (advanced)
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.
