Skip to content

secondsky/claude-skills / plugins/cloudflare-browser-rendering/skills/cloudflare-browser-rendering

cloudflare-browser-rendering

Verified

Cloudflare Browser Rendering with Puppeteer/Playwright. Use for screenshots, PDFs, web scraping, or encountering rendering errors, timeout issues, memory exceeded.

templates/wrangler-browser-config.jsonc

View on GitHub
// Complete wrangler.jsonc configuration for Browser Rendering
{
  "name": "browser-worker",
  "main": "src/index.ts",
  "compatibility_date": "2023-03-14",

  // REQUIRED: nodejs_compat flag for Browser Rendering
  "compatibility_flags": [
    "nodejs_compat"
  ],

  // Browser binding (required)
  "browser": {
    "binding": "MYBROWSER"
    // Optional: Use real headless browser during local development
    // "remote": true
  },

  // Optional: KV for caching screenshots/PDFs
  // Create with: npx wrangler kv namespace create SCREENSHOT_CACHE
  //              npx wrangler kv namespace create SCREENSHOT_CACHE --preview
  "kv_namespaces": [
    {
      "binding": "SCREENSHOT_CACHE",
      "id": "YOUR_KV_ID",           // Replace with actual ID
      "preview_id": "YOUR_PREVIEW_ID"  // Replace with actual preview ID
    }
  ],

  // Optional: R2 for storing generated files
  // Create with: npx wrangler r2 bucket create browser-files
  "r2_buckets": [
    {
      "binding": "BROWSER_FILES",
      "bucket_name": "browser-files"
    }
  ],

  // Optional: AI binding for AI-enhanced scraping
  "ai": {
    "binding": "AI"
  },

  // Optional: D1 for storing scraping results
  // Create with: npx wrangler d1 create browser-db
  "d1_databases": [
    {
      "binding": "DB",
      "database_name": "browser-db",
      "database_id": "YOUR_DB_ID"
    }
  ],

  // Optional: Environment variables
  "vars": {
    "ENVIRONMENT": "production"
  },

  // Optional: Secrets (set with: npx wrangler secret put SECRET_NAME)
  // "secrets": ["API_KEY"]

  // Optional: Custom routes for production
  // "routes": [
  //   {
  //     "pattern": "browser.example.com/*",
  //     "zone_name": "example.com"
  //   }
  // ]
}

/**
 * Key Configuration Notes:
 *
 * 1. nodejs_compat flag is REQUIRED
 *    - Browser Rendering needs Node.js APIs
 *    - Automatically enables nodejs_compat_v2 if compatibility_date >= 2024-09-23
 *
 * 2. Browser binding name
 *    - Use "MYBROWSER" or any name you prefer
 *    - Reference in code: env.MYBROWSER
 *
 * 3. Remote binding for local development
 *    - "remote": true connects to real headless browser
 *    - Useful if hitting 1MB request limit in local dev
 *    - Remove for production (not needed)
 *
 * 4. KV for caching
 *    - Highly recommended for production screenshot services
 *    - Reduces browser usage and costs
 *    - Cache TTL: typically 1-24 hours
 *
 * 5. R2 for file storage
 *    - Store generated PDFs or screenshots long-term
 *    - Cheaper than KV for large files
 *    - Use presigned URLs for downloads
 *
 * 6. AI binding
 *    - Optional: for AI-enhanced scraping
 *    - Requires Workers Paid plan
 *    - See cloudflare-workers-ai skill
 *
 * 7. D1 database
 *    - Optional: store scraping metadata
 *    - Track URLs, timestamps, status
 *    - See cloudflare-d1 skill
 *
 * Commands:
 *   npx wrangler dev          # Local development
 *   npx wrangler deploy       # Deploy to production
 *   npx wrangler tail         # View logs
 *
 * See also:
 *   - cloudflare-worker-base skill for complete Worker setup
 *   - cloudflare-kv skill for KV caching patterns
 *   - cloudflare-r2 skill for R2 storage patterns
 */
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall