@uniformdev/context-next
This package adds Next.js-specific capabilities to Uniform.
Classes
NextCookieTransitionDataStore
Provides client-to-server score transition using cookies for Next.js server-side rendering (SSR). This class is used when creating the Context.
Inherits from
- Constructor
NextCookieTransitionDataStore(options)
Creates a new object using the specified options.
Parameters:
- optionsNextCookieTransitionDataStoreOptions+ show child attributes
- Events
dataUpdatedAsync
Fired when the data is updated asynchronously (i.e. a promise resolves with new data from a backend).
+ show event data members
- Members
dataVisitorData (read-only)
The visitor data.
delete(fromAllDevices)
Deletes a visitor's stored data, forgetting them.
Parameters:
- fromAllDevicesboolean (optional)- If false, logout from this device ID. If true, forget all data about the visitor and their identity.
Returns: Promise<void>
eventsobject (read-only)
Object used to add and remove listeners for the events emitted by the TransitionDataStore.
+ show child attributes
getClientTransitionState()
When we load on the client side after a server side rendering has occurred (server to client transition), we can have a page script (ID:
__UNIFORM_DATA__
) that contains the computed visitor data from the SSR/edge render. This data is injected into the first render to allow score syncing and the server to request commands be applied to the client side data store.Returns:
- ServerToClientTransitionState- Client transition state was resolved.+ show child attributes
- null- No client transition state was resolved.
initialDataVisitorData (read-only)
During server-side rendering we pre-fetch the data before rendering for the visitor, and pass it in here in order to avoid any asynchonry during SSR. This property is set through the constructor.
updateData(commands, computedValue)
Deletes a visitor's stored data, forgetting them.
Parameters:
- commandsStorageCommands[]
- computedValueVisitorData
Returns: Promise<void>