Skip to content

Add Snap docs site#11

Merged
lyoshenka merged 14 commits into
mainfrom
feat/docs-site
Mar 31, 2026
Merged

Add Snap docs site#11
lyoshenka merged 14 commits into
mainfrom
feat/docs-site

Conversation

@rishavmukherji

@rishavmukherji rishavmukherji commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a docs site to the emulator Next.js app at /docs. The emulator itself now lives at farcaster.xyz/~/developers/snaps and is linked externally from the sidebar.

Routes:

  • /docs/* — documentation pages
  • /llms.txt — all docs as plain text for LLM consumption
  • /skill — serves the create-farcaster-snap Claude Code skill for download
  • / redirects to /docs

10 docs pages:

  • Introduction — overview, how snaps work, content negotiation
  • Elements — all 13 element types with properties and examples
  • Buttons — post, link, mini_app, sdk actions
  • Colors — 8-color named palette with visual swatches and light/dark hex values
  • Theme — accent surfaces, what snaps can/can't specify
  • Effects — confetti
  • Constraints — all limits and validation rules
  • Authentication — full JFS spec (format, key types, verification, compact serialization)
  • Examples — example SnapResponse JSON
  • Building a Snap — Claude Code skill install, Hono template, testing, deploying

Features:

  • Farcaster logo (new icon) in sidebar header
  • Collapsible sidebar (Lucide panel icons)
  • Light/dark mode toggle (Moon/Sun icons, persisted to localStorage)
  • Full dark mode support (CSS variables across all pages)
  • Anchor links on all headings (# appears on hover, clickable)
  • Code copy button on code blocks (with fallback + cleanup)
  • llms.txt link in top-right of every docs page
  • Emulator link opens externally in new tab (with ExternalLink icon)

Tech:

  • @next/mdx + remark-gfm (uses --webpack since Turbopack doesn't support remark plugins)
  • lucide-react for icons (MIT)
  • CSS custom properties for full light/dark theme system
  • Custom MDX components for heading anchors and code block copy

Test plan

  • Docs render at /docs/* with proper typography and tables
  • Color palette page shows visual swatches
  • Code copy button works on code blocks
  • Sidebar collapse/expand works
  • Dark mode toggle works and persists across navigation
  • /llms.txt returns aggregated docs as plain text
  • /skill downloads the SKILL.md file
  • / redirects to /docs
  • Emulator link opens farcaster.xyz in new tab
  • CI passes (Build, Test, Typecheck)

🤖 Generated with Claude Code

-claude

Integrates a full docs site into the emulator Next.js app. Docs and
emulator share a single deployment with a unified left sidebar.

Docs pages (10):
- Introduction, Elements, Buttons, Colors (with swatches), Theme,
  Effects, Constraints, Authentication (full JFS spec), Examples,
  Building a Snap (with Claude Code skill install instructions)

Features:
- Farcaster logo in sidebar header
- Collapsible sidebar (Lucide panel icons)
- Light/dark mode toggle (Moon/Sun icons, persisted to localStorage)
- Full dark mode across docs AND emulator (CSS variables)
- Anchor links on all headings (# on hover)
- Code copy button on code blocks (Copy/Check icons)
- /llms.txt route for LLM consumption
- /skill route serves create-farcaster-snap skill for download
- Signature verification hint on 401 errors
- Emulator moved to /emulator, root redirects to /docs

Adapted for farcasterxyz/snap repo:
- @farcaster/snap, @farcaster/snap-hono scoped package names
- application/vnd.farcaster.snap+json accept header
- SKIP_JFS_VERIFICATION env var
- agent-skills/create-farcaster-snap/SKILL.md path

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR integrates a full MDX-based documentation site into the existing @farcaster/snap-emulator Next.js app, shipping docs and emulator together with a shared navigation sidebar, theme system, and a couple of utility routes (/llms.txt, /skill).

Changes:

  • Add MDX docs section under /docs/* (10 pages) plus /llms.txt aggregation and /skill download route.
  • Introduce shared app shell (sidebar + theme toggling) and redirect //docs; move emulator UI to /emulator.
  • Refactor emulator renderer styling to use CSS variables for light/dark theming.

Reviewed changes

Copilot reviewed 28 out of 30 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pnpm-lock.yaml Adds MDX + remark-gfm + lucide dependencies and transitive packages.
apps/emulator/tsconfig.json Includes **/*.mdx for typechecking MDX pages.
apps/emulator/src/components/ThemeProvider.tsx New client theme context + localStorage persistence (docs-theme).
apps/emulator/src/components/SnapRenderer.tsx Swap hardcoded colors for CSS vars for theming consistency.
apps/emulator/src/components/snapCatalogRenderer.tsx Replace hardcoded colors/borders with CSS vars.
apps/emulator/src/components/Sidebar.tsx New shared left sidebar + collapse + theme toggle button.
apps/emulator/src/components/FarcasterLogo.tsx Adds inline SVG Farcaster logo for sidebar branding.
apps/emulator/src/components/CodeBlock.tsx Adds code-block copy-to-clipboard UI for docs pages.
apps/emulator/src/app/skill/route.ts New route to serve SKILL.md as a downloadable file.
apps/emulator/src/app/page.tsx Root now redirects to /docs.
apps/emulator/src/app/llms.txt/route.ts New route aggregating docs MDX content into plain text.
apps/emulator/src/app/layout.tsx Wraps app in ThemeProvider + shared sidebar shell; updates metadata.
apps/emulator/src/app/globals.css Adds CSS-variable theme system + docs/sidebar styling.
apps/emulator/src/app/emulator/page.tsx Moves emulator UI to /emulator and updates colors to CSS vars.
apps/emulator/src/app/emulator/layout.tsx Emulator layout wrapper to constrain overflow appropriately.
apps/emulator/src/app/docs/layout.tsx Docs layout wrapper + llms.txt link.
apps/emulator/src/app/docs/page.mdx Adds docs landing page (Introduction).
apps/emulator/src/app/docs/examples/page.mdx Adds Examples docs page.
apps/emulator/src/app/docs/elements/page.mdx Adds Elements spec docs page.
apps/emulator/src/app/docs/buttons/page.mdx Adds Buttons spec docs page.
apps/emulator/src/app/docs/colors/page.mdx Adds Color Palette docs page with JSX swatches.
apps/emulator/src/app/docs/theme/page.mdx Adds Theme & Styling docs page.
apps/emulator/src/app/docs/effects/page.mdx Adds Effects docs page.
apps/emulator/src/app/docs/constraints/page.mdx Adds Constraints docs page.
apps/emulator/src/app/docs/building/page.mdx Adds Building a Snap guide.
apps/emulator/src/app/docs/auth/page.mdx Adds Authentication (JFS) docs page.
apps/emulator/package.json Adds MDX + remark + lucide deps; uses --webpack for builds.
apps/emulator/next.config.ts Enables MDX via @next/mdx and remark-gfm; adds page extensions.
apps/emulator/next-env.d.ts Adjusts Next route types import path.
apps/emulator/mdx-components.tsx Custom MDX components: heading anchors + CodeBlock wrapper.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/emulator/src/components/Sidebar.tsx
Comment thread apps/emulator/src/components/CodeBlock.tsx Outdated
Comment thread apps/emulator/src/app/llms.txt/route.ts Outdated
rishavmukherji and others added 6 commits March 30, 2026 23:46
The emulator now lives at farcaster.xyz which signs messages
automatically, eliminating signature bypass issues for developers.

- Sidebar emulator link is now external (opens new tab, ExternalLink icon)
- Updated Building a Snap guide to link to hosted emulator
- Removed signature bypass instructions from testing section

The local /emulator route is kept for development but no longer
linked from the docs navigation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The port agent accidentally downgraded version ranges in
template/package.json, causing lockfile mismatch in CI.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add aria-label to sidebar collapse/expand button
- CodeBlock: add clipboard fallback (execCommand), error handling,
  and timeout cleanup on unmount
- Fix llms.txt palette-stripping regex to match actual markup

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@rishavmukherji rishavmukherji changed the title Add docs site integrated with emulator Add Snap docs site Mar 31, 2026
rishavmukherji and others added 7 commits March 31, 2026 01:11
Covers content negotiation (Accept header routing), with examples for:
- Dynamic sites (Hono, Express middleware)
- Static sites (Cloudflare Worker, Vercel Edge Middleware, separate URL)
- POST handling and testing

Added to sidebar, and included in /llms.txt.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Elements page: added inline visual previews for text, divider,
  progress, list, grid, text_input, slider, button_group, toggle,
  bar_chart, and group elements
- Added callout linking to live Element Showcase in emulator
- Building page: skill download URL now points to GitHub raw URL
  (farcasterxyz/snap repo) with link to view source on GitHub

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…errors

Elements page improvements:
- Image element: real sample image from picsum.photos
- Video element: play button placeholder preview
- Divider element: realistic usage context (poll results separator)
- First Page: complete valid SnapResponse example
- Common Validation Errors section with 5 examples:
  no title/body, no interactive/media, too many elements,
  two media elements, hex accent instead of palette name

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Grid: multi-row with tappable empty cells, shows tap coordinates
- Video: thumbnail image with play button overlay
- Text input: actually typeable (native HTML input)
- Button group: tappable with selection highlighting (client component)
- Valid first page: visual SnapCard preview with interactive buttons
- All 5 validation errors: SnapCard previews showing what the broken
  snap would look like, with red VALIDATION ERROR badge

New client components:
- InteractiveGrid: stateful grid with tappable cells
- InteractiveButtonGroup: stateful option selector
- SnapCard: styled card wrapper with valid/invalid states

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Interactive ConfettiDemo component shows the confetti effect in a
snap card preview with a "Replay confetti" button. Animates 60
particles with varied colors, shapes, and fall patterns.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Effects fire when any page is rendered, not just on initial load.
A POST button tap returning a page with effects will trigger them.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@lyoshenka
lyoshenka merged commit 37e5fc8 into main Mar 31, 2026
3 checks passed
@lyoshenka
lyoshenka deleted the feat/docs-site branch March 31, 2026 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants