AI SummaryCursor rules quickstart for integrating Stagehand V3 browser automation into NextJS projects. Developers building AI-powered browser automation workflows benefit from ready-to-use initialization and pattern examples.
Install
Copy this and paste it into Claude Code, Cursor, or any AI assistant:
I want to add the "stagehand-nextjs-quickstart — Cursor Rules" prompt rules to my project. Repository: https://github.com/browserbase/stagehand-nextjs-quickstart Please read the repo to find the rules/prompt file, then: 1. Download it to the correct location (.cursorrules, .windsurfrules, .github/prompts/, or project root — based on the file type) 2. If there's an existing rules file, merge the new rules in rather than overwriting 3. Confirm what was added
Description
A quickstart for NextJS
Basic Agent Usage
`typescript const page = stagehand.context.pages()[0]; await page.goto("https://www.google.com"); const agent = stagehand.agent({ model: "google/gemini-2.0-flash", executionModel: "google/gemini-2.0-flash", }); const result = await agent.execute({ instruction: "Search for the stock price of NVDA", maxSteps: 20, }); console.log(result.message); `
Agent with Integrations (MCP/External Tools)
`typescript const agent = stagehand.agent({ integrations: [https://mcp.exa.ai/mcp?exaApiKey=${process.env.EXA_API_KEY}], systemPrompt: You have access to the Exa search tool., }); `
Stagehand Project
This is a project that uses Stagehand V3, a browser automation framework with AI-powered act, extract, observe, and agent methods. The main class can be imported as Stagehand from @browserbasehq/stagehand. Key Classes: • Stagehand: Main orchestrator class providing act, extract, observe, and agent methods • context: A V3Context object that manages browser contexts and pages • page: Individual page objects accessed via stagehand.context.pages()[i] or created with stagehand.context.newPage()
Initialize
`typescript import { Stagehand } from "@browserbasehq/stagehand"; const stagehand = new Stagehand({ env: "LOCAL", // or "BROWSERBASE" verbose: 2, // 0, 1, or 2 model: "openai/gpt-4.1-mini", // or any supported model }); await stagehand.init(); // Access the browser context and pages const page = stagehand.context.pages()[0]; const context = stagehand.context; // Create new pages if needed const page2 = await stagehand.context.newPage(); `
Discussion
Health Signals
My Fox Den
Community Rating
Sign in to rate this booster
Works With
Any AI assistant that accepts custom rules or system prompts