building-canvases

Create and publish sandboxed browser canvas applications inside PostHog.

713|118|Updated Aug 11, 2020
One-click install
npx skills add https://github.com/PostHog/posthog-foss --skill building-canvases
Or copy as Structured Prompt for Agentβ–Ό
Please help me install this Agent Skill.
Skill: building-canvases
Source: https://github.com/PostHog/posthog-foss/tree/main/products/canvas/skills/building-canvases
Command: npx skills add https://github.com/PostHog/posthog-foss --skill building-canvases

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Building a standalone app that lives inside PostHog requires knowing how to resolve the right target canvas, choose between React/Quill and plain HTML implementations, declare data capabilities, and follow the read β†’ edit β†’ validate β†’ publish β†’ build loop. This Skill orchestrates that entire lifecycle so canvas apps are created, validated, and published correctly through the canvas tools.

Core Features & Use Cases

  • Target resolution and lifecycle ownership: Resolves or creates the correct freeform canvas in the right channel, then drives the read β†’ edit β†’ validate β†’ publish/draft β†’ build loop with guarded version publishing.
  • Implementation routing: Directs work to companion skills for React + Quill apps, plain HTML/graphics canvases, PostHog data querying via the ph SDK, and validation/publishing.
  • Runtime capabilities: Covers ph.state durable memory, ph.actions.invoke write actions, ph.agent.request agent calls, and media library image uploads with CSP origin declarations.
  • Use Case: A user asks for a web analytics dashboard living in PostHog. The Skill resolves the channel's canvas, builds a React + Quill app querying saved insights, declares capabilities, validates, stages a draft, and waits for the build to succeed.

Quick Start

Ask the agent to build a PostHog canvas app, for example: create a product metrics dashboard canvas in the current channel using saved insights.

Frequently Asked Questions about building-canvases

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a canvas app in PostHog?β–Ό

Resolve the target canvas with canvas-list or create one with canvas-create in the task's channel, then edit the project source, validate with canvas-validate-create, and publish with canvas-publish-create or stage a draft with canvas-draft-create. Poll canvas-builds-retrieve until the build is ready.

Should I use React and Quill or plain HTML for a PostHog canvas?β–Ό

Use React + Quill for dashboards, forms, tools, and anything that should look native to PostHog. Use plain HTML and browser APIs for documents, generative graphics, and WebGL experiments where application components add no structure. The two approaches can be mixed.

How does a PostHog canvas query product data?β–Ό

Canvases read PostHog data through the ph SDK, preferring saved insights loaded by short id, with support for ad-hoc inline queries, variables, and date ranges. Every ph call must be declared in project.capabilities or validation rejects it and the host blocks it at runtime.

Can a canvas store state or write back into PostHog?β–Ό

Yes, ph.state provides durable key-value memory with user or shared scope, and ph.actions.invoke performs write actions as the viewer when wired to explicit clicks. Both must be declared in capabilities, and state values are capped at 64 KB with 256 keys per scope.

When should I use composing-grid-canvases instead of building-canvases?β–Ό

Use composing-grid-canvases when the target is a grid or home canvas, a widget placement, or a reusable component, since it owns the store search, configure, fork, and layout patch flow. building-canvases owns standalone freeform canvas apps only.

Why does canvas validation fail after adding an image?β–Ό

Validation fails when the image origin is not declared in project.capabilities.network.origins, since the published artifact's Content Security Policy depends on that declaration. Upload images through the media library flow and add the returned URL's exact origin to the capabilities.