| features |
|
||||||
|---|---|---|---|---|---|---|---|
| languages |
|
This tutorial demonstrates how to connect custom renderers to the Aidbox Forms Builder preview.
The Aidbox Forms Builder allows you to use custom renderers to display questionnaires with your own UI components. This example shows how to:
- Host a renderer page that speaks SDC SMART Web Messaging
- Register renderer URLs in Aidbox
- Use them in the Forms Builder preview
- Running Aidbox
git clone <this-repo>
cd aidbox-forms-builder-custom-renderer
git submodule update --init --recursiveThis repo includes renderer pages:
smart-forms-renderer(Smart Forms)lhc-forms-renderer(LHC-Forms via hosted build)beda-renderer(Beda FHIR Questionnaire renderer)refero-renderer(Refero)
cd smart-forms-renderer
pnpm install
pnpm buildFor other renderers, run the same commands from their folders.
If you want to host the renderer elsewhere, repeat the same steps in that environment.
The Forms Builder loads a renderer by URL. The renderer page must implement SDC SMART Web Messaging and respond to postMessage requests from the host.
Each renderer page in this repo is a Vite app (index.html + src/index.tsx/src/index.ts) that builds to a static dist/ folder, mounts a renderer (Smart Forms, LHC-Forms, Beda, or Refero), and bridges messages to the host.
The renderer page must be accessible via URL. You can use either:
- Vite dev server (local testing):
cd smart-forms-renderer
pnpm devIf you are using a different folder (e.g. lhc-forms-renderer), run the same command from there instead.
- Built files hosted anywhere (for preview):
pnpm buildThen host the resulting dist/ folder with any static hosting.
Open Forms Builder and use the renderer switcher (eye icon near the theme selector).
- Click Add custom renderer
- Enter a name and the renderer URL (for example
http://localhost:5173) - Save
- Access Forms Builder: Go to http://localhost:8080 and navigate to Forms Builder
- Create/Edit Questionnaire: Use the visual editor to build your form
- Preview with Custom Renderer: In the preview section, select your custom renderer from the dropdown
- Test: The preview will use your custom renderer instead of the default one
Service URLs:
- Aidbox: http://localhost:8080
- Renderer dev server: http://localhost:5173 (default Vite port)
-
Renderer not appearing in Forms Builder:
- Verify the renderer URL is reachable
- Check browser console for loading errors
-
Response not updating:
- Check browser console for postMessage errors
- Confirm renderer page receives
sdc.displayQuestionnaire - Verify the renderer sends
sdc.ui.changedQuestionnaireResponse
-
CORS issues:
- Ensure renderer URL is accessible from Forms Builder domain
- Check network tab for failed requests
- Test renderer directly: http://localhost:5173
- Check browser console in Forms Builder for errors
This example provides a complete foundation for integrating custom renderers that work seamlessly with the Aidbox Forms Builder.