@wix/site-service-dynamic-route
v1.0.14
Published
Read-only access to the current route's dynamic route payload.
Maintainers
Keywords
Readme
@wix/site-service-dynamic-route
Read-only access to the current route's dynamic route payload.
Install
pnpm add @wix/site-service-dynamic-routeUsage
import { DynamicRouteDefinition } from '@wix/site-service-dynamic-route/definition'
import { DynamicRouteService } from '@wix/site-service-dynamic-route/implementations'
createServicesMap().addService(DynamicRouteDefinition, DynamicRouteService, config)
const service = servicesManager.getService(DynamicRouteDefinition)
service.dynamicRouteDataAPI
| Member | Type | Throws when | Description |
|---|---|---|---|
| dynamicRouteData | DynamicRouteData \| null | never | Full dynamic route payload for the current route, or null when absent. |
| routerData | unknown | never | dynamicRouteData.pageData, or null when absent. |
| publicData | unknown | never | dynamicRouteData.publicData, or null when absent. |
Configuration
IDynamicRouteServiceConfig:
type DynamicRouteData<TPageData = unknown, TPageHeadData = unknown, TPublicData = unknown> = {
pageData?: TPageData
pageHeadData?: TPageHeadData
publicData?: TPublicData
}
type IDynamicRouteServiceConfig<TPageData = unknown, TPageHeadData = unknown, TPublicData = unknown> = {
dynamicRouteData?: DynamicRouteData<TPageData, TPageHeadData, TPublicData> | null
}dynamicRouteData is optional because most routes are not dynamic routes. Missing nested fields are exposed as null through the dedicated convenience getters.
Reactivity
This is a static read-only service. Values are captured from config at initialization and do not update at runtime.
