Repository files navigation # bloggrs.sdk
Embeddable runtime and bridge package for Bloggrs published products and live builder previews.
## Runtime API
- `new BloggrsClient({ baseUrl })`
- `client.getProduct(slug)`
- `client.getDocument(slug, routePath)`
- `mountProduct(target, { baseUrl, slug, routePath })`
- `mountProduct(target, { baseUrl, preview, routePath })`
- `mountPreviewProduct(target, { baseUrl, preview, routePath })`
The SDK mounts HTML, CSS, and JS published by the Bloggrs public product API and can also render preview payloads streamed directly from builders.
Preview payloads support:
- `documents`
- optional `navigation`
- `contentModels`
- `collections`
- document `dataBindings` for collection-driven slot rendering
Shell rendering is customizable with the `shell` option:
- `enabled`
- `title`
- `showNavigation`
- custom class names
- custom stylesheet
- custom shell `render(context)`
## Iframe Bridge
The SDK also ships a typed parent and iframe bridge for the Bloggrs platform shell and builder previews.
Exports:
- `createBloggrsParentBridge(...)`
- `createBloggrsChildBridge(...)`
- `resolveOrigin(url)`
- `resolveParentOriginFromDocument(referrer, fallbackOrigin?)`
Local app identities now include:
- `platform`
- `playground`
- `scratch`
- `platform-blog`
Protocol coverage:
- strict origin checks on both parent and child
- request/response ids with timeouts
- handshake and readiness
- health ping
- route sync and route changed events
- resize sync
- theme sync
- session propagation
- draft changed events
- builder state snapshots
- builder product selection
- builder workspace load commands
- shell action requests
- save and publish requests
- notification events
Key request types:
- `bridge.handshake`
- `bridge.health.ping`
- `bridge.route.sync`
- `bridge.session.sync`
- `bridge.theme.sync`
- `bridge.builder.state.get`
- `bridge.builder.product.select`
- `bridge.builder.workspace.load`
- `bridge.save.request`
- `bridge.publish.request`
Key event types:
- `bridge.ready`
- `bridge.resize.sync`
- `bridge.route.changed`
- `bridge.draft.changed`
- `bridge.builder.state.changed`
- `bridge.action.request`
- `bridge.notification`
Local verification:
- `npm run build`
- `npm run verify:bridge`
`verify:bridge` spins up a fake parent/child message pair and asserts handshake, theme/session sync, builder state requests, product selection, workspace load, save/publish responses, route sync, resize sync, notification delivery, and rogue-origin rejection.
# bloggrs.sdk
You can’t perform that action at this time.