<Go>)Interactive examples allow users to preview and edit code directly in the documentation. This guide explains how to manage these examples using the dedicated workspace and the <Go> component.
The interactive example system allows you to embed live, runnable Lynx code in your documentation. It consists of:
packages/lynx-example-packages/.<Go> Component: A React component that renders the interactive editor and preview in your MDX files.<Go> ComponentTo embed an interactive example in your documentation, use the <Go> component.
Import Go from @lynx and provide the example ID (which corresponds to the package directory name).
| Prop | Type | Default | Description |
|---|---|---|---|
example | string | Required | The ID of the example to load (e.g., "view"). Matches the directory name in docs/public/lynx-examples/. |
defaultFile | string | "package.json" | The file path to display in the code editor initially. |
defaultEntryName | string | - | The specific entry point to run (if the example has multiple bundles). |
img | string | - | URL to a custom preview image (overrides the default preview-image.png). |
highlight | object | - | Line highlighting configuration. Format: { "path/to/file": "start-end" }. |
schema | string | - | Custom schema URL pattern for the preview. Use {{{url}}} as a placeholder for the bundle URL. |
All interactive examples are managed as dependencies in the packages/lynx-example-packages/ workspace.
To make a new example available to the <Go> component:
@lynx-example/my-feature).packages/lynx-example-packages/package.json.pnpm install in the workspace root to download the new example.For those interested in how it works under the hood:
scripts/lynx-example.js runs during the build.node_modules/@lynx-example/ for packages..lynx.bundle, .web.bundle) and source code.example-metadata.json for each example.docs/public/lynx-examples/.<Go> component fetches this metadata at runtime to hydrate the editor and preview.