Automate browser tasks using Anthropic’s Claude with sophisticated computer use capabilities
Claude Computer Use enables Claude to interact with web browsers like a human by moving the cursor, clicking elements, typing text, and navigating pages. This lets you automate complex, multi-step workflows with natural language instructions.Hyperbrowser provides a managed Claude Computer Use agent that handles session management, browser infrastructure, and task execution. You simply describe what you want done, and Claude figures out how to do it.You can view your Claude Computer Use tasks in the dashboard.
The simplest way to run a Claude Computer Use task is with the startAndWait() method, which handles everything for you:
Copy
Ask AI
import { Hyperbrowser } from "@hyperbrowser/sdk";import { config } from "dotenv";config();const client = new Hyperbrowser({ apiKey: process.env.HYPERBROWSER_API_KEY,});async function main() { const result = await client.agents.claudeComputerUse.startAndWait({ task: "Go to Hacker News and tell me the title of the top post", llm: "claude-sonnet-4-5", maxSteps: 20, }); console.log(`Output:\n${result.data?.finalResult}`);}main().catch((err) => { console.error(`Error: ${err.message}`);});
Allow the agent to interact by executing actions on the actual computer not just within the page. Allows the agent to see the entire screen instead of just the page contents.
Session configuration (proxy, stealth, captcha solving, etc.). Only applies when creating a new session. If you provide an existing sessionId, these options are ignored.
API key for anthropic. Required when useCustomApiKeys is true.
Copy
Ask AI
{ anthropic: "..."}
The agent may not complete the task within the specified maxSteps. If that happens, try increasing the maxSteps parameter.Additionally, the browser session used by the AI Agent will time out based on your team’s default Session Timeout settings or the session’s timeoutMinutes parameter if provided. You can adjust the default Session Timeout in the Settings page.
useComputerAction can often be better for completing tasks but may require more steps. It is especially useful when the agent needs to interact with elements on the page that might not be accessible by or visible to Playwright. Since it allows the agent to see and interact with the entire screen, it is much more powerful. Instead of executing actions with Playwright which can only interact with the page via CDP, computer actions allow the agent to interact directly with computer primitives (direct clicks, typing, scroll, etc.).
You can pass in an existing sessionId to the Claude Computer Use task so that it can execute the task on an existing session. Also, if you want to keep the session open after executing the task, you can supply the keepBrowserOpen parameter.
Copy
Ask AI
import { Hyperbrowser } from "@hyperbrowser/sdk";import { config } from "dotenv";config();const client = new Hyperbrowser({ apiKey: process.env.HYPERBROWSER_API_KEY,});const main = async () => { const session = await client.sessions.create(); try { const result = await client.agents.claudeComputerUse.startAndWait({ task: "What is the title of the first post on Hacker News today?", sessionId: session.id, keepBrowserOpen: true, }); console.log(`Output:\n${result.data?.finalResult}`); const result2 = await client.agents.claudeComputerUse.startAndWait({ task: "Tell me how many upvotes the first post has.", sessionId: session.id, }); console.log(`\nOutput:\n${result2.data?.finalResult}`); } catch (err) { console.error(`Error: ${err}`); } finally { await client.sessions.stop(session.id); }};main().catch((err) => { console.error(`Error: ${err.message}`);});
Always set keepBrowserOpen: true on tasks that you want to reuse the session from. Otherwise, the session will be automatically closed when the task completes.
Bring your own Anthropic API key to avoid consuming Hyperbrowser credits for LLM calls. You’ll still be charged for browser session usage, but save on token costs.
Copy
Ask AI
import { Hyperbrowser } from "@hyperbrowser/sdk";import { config } from "dotenv";config();const client = new Hyperbrowser({ apiKey: process.env.HYPERBROWSER_API_KEY,});const main = async () => { const result = await client.agents.claudeComputerUse.startAndWait({ task: "What is the title of the first post on Hacker News today?", llm: "claude-sonnet-4-5", useCustomApiKeys: true, apiKeys: { anthropic: "<ANTHROPIC_API_KEY>", }, }); console.log(`Output:\n\n${result.data?.finalResult}`);};main().catch((err) => { console.error(`Error: ${err.message}`);});
Customize the browser session used by Claude Computer Use with session options.
Copy
Ask AI
import { Hyperbrowser } from "@hyperbrowser/sdk";import { config } from "dotenv";config();const client = new Hyperbrowser({ apiKey: process.env.HYPERBROWSER_API_KEY,});const main = async () => { const result = await client.agents.claudeComputerUse.startAndWait({ task: "What is the title of the first post on Hacker News today?", llm: "claude-sonnet-4-5", sessionOptions: { acceptCookies: true, } }); console.log(`Output:\n\n${result.data?.finalResult}`);};main().catch((err) => { console.error(`Error: ${err.message}`);});
sessionOptions only applies when creating a new session. If you provide a sessionId, these options are ignored.
Proxies and CAPTCHA solving add latency to page navigation. Only enable them when necessary for your use case.
Be explicit about what you want Claude to do. Instead of “check the website”, say “go to example.com, find the pricing page, and extract the cost of the Enterprise plan”.
Set appropriate maxSteps
Simple tasks need 10-20 steps. Complex multi-page workflows might need 50+ steps. Monitor failed tasks and adjust accordingly.
Reuse sessions for multi-step workflows
It is usually better to split up complex tasks into smaller, more manageable ones and execute them as separate agent calls on the same session.