Documentation for automated readers
A curated documentation index is available at: https://grafana.com/llms.txt
A complete documentation index is available at: https://grafana.com/llms-full.txt
These indexes can help with page discovery before fetching individual documents.
This page is also available in Markdown, which may be easier for automated readers and AI tools to parse than HTML. The Markdown version is available at https://grafana.com/docs/grafana-cloud/ai-tools/gcx/resources/build-grafana-pages.md, or by sending Accept: text/markdown to https://grafana.com/docs/grafana-cloud/ai-tools/gcx/resources/build-grafana-pages/. For broader documentation discovery, the curated index is available at https://grafana.com/llms.txt and the complete index is available at https://grafana.com/llms-full.txt.
Build Grafana Pages
A Grafana Page is a live web page on your Grafana data, such as a report, an incident summary, or a slideshow. It’s a small React and TypeScript project that your stack builds and serves in Grafana, where its queries run as each viewer. Use gcx to write a page in a local directory, with your own editor or a coding agent, and let the stack build it. Pages commands are experimental and require Grafana Cloud.
Before you begin
- Configure a gcx context for a Grafana Cloud stack with Grafana Pages enabled and a version of Grafana Assistant that accepts gcx’s Pages commands.
- To publish or pull a published page, sign in with
gcx login. A service account token can build new drafts, but can’t publish or edit published pages.
gcx pages catalog finds and reads published pages. gcx pages drafts writes, builds, and publishes the pages you work on in a local directory. Commands use your selected context. Add --context CONTEXT to select another context. These commands don’t run Grafana Assistant.
Start a page
Create a draft page and write its project into a new directory:
gcx pages drafts create --title "Checkout health" --dir ./checkout-healthThe directory holds the whole project: page.json, pages.bindings.json for the page’s queries, src/App.tsx, and the Pages SDK with its documentation under packages/pages-sdk/. Start with packages/pages-sdk/README.md. The .gcx-page.json file links the directory to the draft; keep it.
The draft is private to you until you publish it.
Build and check the page
To build the page and check how it renders, follow these steps:
Add a named query to
pages.bindings.json. ReplaceDATASOURCE_UIDwith the UID of a Prometheus data source:JSON{ "requests": { "title": "Checkout requests per second", "datasourceUid": "DATASOURCE_UID", "query": { "expr": "sum(rate(http_requests_total{service=\"checkout\"}[5m]))", "range": true } } }Show it in
src/App.tsx:tsximport { GrafanaPanel, TimeRangePicker, useQuery } from '@grafana/pages'; export function App() { const requests = useQuery('requests'); return ( <main> <h1>Checkout health</h1> <TimeRangePicker /> <div data-page-sources='["requests"]'> <GrafanaPanel data={requests} pluginId="timeseries" title="Requests per second" /> </div> </main> ); }Build it on your stack:
shellgcx pages drafts push --dir ./checkout-healthPush sends the files that changed. If the page doesn’t build, the command lists the type and build errors, and the draft keeps its previous version.
Render the latest build, with live data, as an image:
shellgcx pages drafts snapshot --dir ./checkout-health --output-dir ./snapshotsOpen the image and check the layout and data. A page that builds can still render incorrectly.
The output of push includes the draft’s address in Grafana.
Change a published page
Download a published page’s source:
gcx pages catalog list --section mine
gcx pages drafts pull PAGE --dir ./checkout-health-copyReplace PAGE with the page’s ID or link. The directory must be new or empty. pull only reads: it writes the page’s source as text, without the Pages SDK under packages/ and the stylesheets, which stay on the stack.
Edit the files, then push. The first push builds a draft from the page and sends only the files you changed; it refuses if someone published a newer version since you pulled. Check the draft as before. Publishing it makes your changes the page’s next version.
After the first push, download the draft’s whole project, SDK included:
gcx pages drafts pull --dir ./checkout-health-copyA draft of another person’s page leaves out their agent guidance and the SDK’s Markdown docs, and lists them under omitted in JSON or YAML output. The stack builds the draft with the template’s guidance.
If the draft changes in Grafana, for example when you ask Grafana Assistant to change it, download it again before you edit:
gcx pages drafts pull --dir ./checkout-health-copyThis refuses while the directory has changes you haven’t pushed. Push them first, or add --force to discard them.
gcx resources pull also downloads published pages, as Page objects, but those hold only a page’s catalog details: its title, description, category, and tags. To copy or change a page, use gcx pages drafts pull and gcx pages drafts push, not gcx resources push.
Publish the page
Publishing shares the page:
gcx pages drafts publish --dir ./checkout-health --folder FOLDER_UID --category reportEveryone who can view the folder can open the page. To publish without a folder, use --unlisted: only you can open the page, unless you add --link-sharing to let anyone in your organization with the link open it.
Publishing uses the draft’s last successful build, not your local files. If the directory has changes you haven’t pushed, publish warns you and publishes the earlier build, so push first.
A page you pulled, or published before, keeps its folder and sharing, and earlier versions stay in its history. To change its folder or sharing, use Grafana, then publish without --folder, --unlisted, or --link-sharing.
Use Pages with coding agents
The grafana-pages agent skill explains the page project, the SDK, query bindings, and how pages run, and asks agents to build a Page instead of an artifact or a standalone HTML file when your stack has Pages. To install it, refer to Use gcx with agents.
Limits
pushwrites text files of up to 120 KiB. Use SVG for images you add.- Pages build with the packages in the project’s
package.json; gcx can’t install others. - A page runs in an isolated frame without network access. Its data comes from its queries, which run as each viewer.
Was this page helpful?
Related resources from Grafana Labs


