1. Let your app read the API
Runhatchmark serve as in Production. An app served from the same origin needs
no setting. An app on another origin needs that origin listed:
/_hatchmark/static/ through without a sign-in, and nothing else: browsers load the script
from there without cookies from another origin. That path serves only the script, its chunks, fonts
and map boundaries, which never change once built and hold none of your data. The API, the pages
and the other files under /_hatchmark/ stay behind your sign-in.
2. Add charts to a plain HTML page
Load the script serve hands out and place a chart per block, named<dashboard>.<block id>:
<hatchmark-scope> share its endpoint and theme, and a pick in one filters the others.
The script comes from the same build as the API, so the two always match. Set id: on every block
you embed (Dashboards): a block without one is named by its
position, which changes when blocks move.
3. Use the React components
period and filters take the values the dashboard’s filters offer. To read a block’s numbers for
your own UI, such as its as-of date, call useHatchmarkBlock. Install @hatchmark/react at the
version of hatchmark your serve runs.
To catch a misspelled block, period or filter when your app compiles, save the build’s types into
your app and commit them:
_hatchmark/api/types.d.ts in the folder you pass to hatchmark serve --out.
Fetch them again when you add or rename blocks or filters.
4. Draw charts on the server with Next.js
Fetch a block in a server component and hand it to the chart, which then shows before any script runs and doesn’t fetch it again:fetchBlock reads serve’s API from HATCHMARK_URL, such as http://hatchmark:4000/api/v1 inside
your network, and passes your gateway’s headers with headers.
5. Follow picks in your app
A pick fireshatchmark-pick on the scope, or onPick on the provider, with every pick on screen:
picks makes the provider controlled, so your app can show, clear or set them.