@ogygia/federation · API
@ogygia/federation/shared
SharedState, one page-wide value that islands from separate builds share.
This page is generated from the package’s own .d.ts files on every build, so the signatures, descriptions and examples below always match the source.
import { … } from '@ogygia/federation/shared';Exports SharedState
SharedState
class
One page-wide value that islands from separate builds share. Every build's copy of the class
meets at one page store under the same name. Read and write .current; values must be plain
data (devalue-serializable). A server can seed the opening value with <script type="application/json" data-og-shared="<name>">, and plain scripts can join through globalThis.ogygia.shared(name).
class SharedState<T extends object> {/*…*/}import { SharedState } from '@ogygia/federation/shared';
export const cart = new SharedState('cart', { items: [] as string[] });SharedState.constructor
constructor(name: string, initial: T);SharedState.current
The value — reactive wherever Svelte is watching, plain everywhere else.
get current(): T;SharedState.current
The value — reactive wherever Svelte is watching, plain everywhere else.
set current(v: T);