Functions
BrowserbaseOfficialPublished by Browserbase
- Skill
- Tool integration
- Automation and integrations
- MIT
- Low risk
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured approach to creating, testing, and deploying serverless browser automation functions. By leveraging the Browserbase platform, users can move local automation scripts into a cloud environment, enabling execution on schedules or via webhooks. The process involves initializing a project, writing automation logic using Playwright, testing locally with a development server, and publishing the final function to the cloud.
What it does
- Initializes new browser automation projects with necessary boilerplate code
- Provides a local development environment for testing browser tasks
- Facilitates the deployment of browser automation scripts to the cloud
- Supports the use of Playwright for browser interaction within serverless functions
- Enables the management of browser automation tasks via a command line interface
When to use it
- When you need to run browser automation tasks on a recurring schedule
- When you want to trigger browser tasks via webhooks
- When you need to move local browser automation scripts to a cloud-based execution environment
- When you are working with Browserbase Functions
Advantages
- Allows for serverless execution of browser tasks
- Simplifies the transition from local development to cloud deployment
- Supports local testing and iteration before publishing
- Integrates directly with the Browserbase platform
Usage examples
- “How do I start a new Browserbase function project?”
- The agent will guide you to use the browse functions init command to create a new project structure with the required configuration files.
- “How can I test my automation locally before deploying?”
- The agent will instruct you to use the browse functions dev command to start a local server, allowing you to invoke and test your function locally.
- “How do I deploy my finished browser automation to the cloud?”
- The agent will explain how to use the browse functions publish command to upload your function code to the Browserbase platform.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/browserbase/functions/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip functions.zip -d .agents/skills
Documentation by Browserbase
Browserbase Functions
Deploy serverless browser automation using the official browse CLI.
Prerequisites
Get an API key from: https://browserbase.com/settings
export BROWSERBASE_API_KEY="your_api_key"Creating a Function Project
1. Initialize
browse functions init my-function
cd my-functionThis creates:
my-function/
├── package.json
├── index.ts # Your function code
└── .env # Add credentials here2. Add Credentials to .env
echo "BROWSERBASE_API_KEY=$BROWSERBASE_API_KEY" >> .env3. Install Dependencies
pnpm installFunction Structure
import { defineFn } from "@browserbasehq/sdk-functions";
import { chromium } from "playwright-core";
defineFn("my-function", async (context) => {
const { session, params } = context;
// Connect to browser
const browser = await chromium.connectOverCDP(session.connectUrl);
const page = browser.contexts()[0]!.pages()[0]!;
// Your automation
await page.goto(params.url || "https://example.com");
const title = await page.title();
// Return JSON-serializable result
return { success: true, title };
});Key objects:
context.session.connectUrl- CDP endpoint to connect Playwrightcontext.params- Input parameters from invocation
Development Workflow
1. Start Dev Server
browse functions dev index.tsServer runs at http://127.0.0.1:14113
2. Test Locally
curl -X POST http://127.0.0.1:14113/v1/functions/my-function/invoke \
-H "Content-Type: application/json" \
-d '{"params": {"url": "https://news.ycombinator.com"}}'3. Iterate
The dev server auto-reloads on file changes. Use console.log() for debugging - output appears in the terminal.
Deploying
browse functions publish index.tsOutput:
Function published successfully
Build ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Function ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxSave the Function ID - you need it to invoke.
Quick Reference
| Command | Description |
|---|---|
browse functions init <name> | Create new project |
browse functions dev <file> | Start local dev server |
browse functions publish <file> | Deploy to Browserbase |
For invocation examples, common patterns, and troubleshooting, see REFERENCE.md.
Files
- ATTRIBUTION.mdAdded by AutoGineer858 B
- LICENSE.txt1.0 KiB
- REFERENCE.md3.8 KiB
- SKILL.md2.9 KiB
REFERENCE.md
Browserbase Functions Reference
Table of Contents
Invoking Deployed Functions
Common Patterns
Troubleshooting
Invoking Deployed Functions
Via curl
# Start invocation
curl -X POST "https://api.browserbase.com/v1/functions/FUNCTION_ID/invoke" \
-H "Content-Type: application/json" \
-H "x-bb-api-key: $BROWSERBASE_API_KEY" \
-d '{"params": {"url": "https://example.com"}}'
# Response: {"id": "INVOCATION_ID"}
# Poll for result
curl "https://api.browserbase.com/v1/functions/invocations/INVOCATION_ID" \
-H "x-bb-api-key: $BROWSERBASE_API_KEY"Via Code
async function invokeFunction(functionId: string, params: object) {
// Start invocation
const invokeRes = await fetch(
`https://api.browserbase.com/v1/functions/${functionId}/invoke`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-bb-api-key': process.env.BROWSERBASE_API_KEY!,
},
body: JSON.stringify({ params }),
}
);
const { id: invocationId } = await invokeRes.json();
// Poll until complete
while (true) {
await new Promise(r => setTimeout(r, 5000));
const statusRes = await fetch(
`https://api.browserbase.com/v1/functions/invocations/${invocationId}`,
{ headers: { 'x-bb-api-key': process.env.BROWSERBASE_API_KEY! } }
);
const result = await statusRes.json();
if (result.status === 'COMPLETED') return result.results;
if (result.status === 'FAILED') throw new Error(result.error);
}
}Common Patterns
Parameterized Scraping
defineFn("scrape", async ({ session, params }) => {
const browser = await chromium.connectOverCDP(session.connectUrl);
const page = browser.contexts()[0]!.pages()[0]!;
await page.goto(params.url);
await page.waitForSelector(params.selector);
const items = await page.$$eval(params.selector, els =>
els.map(el => el.textContent?.trim())
);
return { url: params.url, items };
});With Authentication
defineFn("authenticated-action", async ({ session, params }) => {
const browser = await chromium.connectOverCDP(session.connectUrl);
const page = browser.contexts()[0]!.pages()[0]!;
// Login
await page.goto("https://example.com/login");
await page.fill('[name="email"]', params.email);
await page.fill('[name="password"]', params.password);
await page.click('button[type="submit"]');
await page.waitForURL('**/dashboard');
// Do authenticated work
const data = await page.textContent('.user-data');
return { data };
});Error Handling
defineFn("safe-scrape", async ({ session, params }) => {
const browser = await chromium.connectOverCDP(session.connectUrl);
const page = browser.contexts()[0]!.pages()[0]!;
try {
await page.goto(params.url, { timeout: 30000 });
await page.waitForSelector(params.selector, { timeout: 10000 });
const data = await page.textContent(params.selector);
return { success: true, data };
} catch (error) {
return {
success: false,
error: error instanceof Error ? error.message : 'Unknown error'
};
}
});Troubleshooting
"Missing API key"
# Check .env file has credentials
cat .env
# Or set for current shell
export BROWSERBASE_API_KEY="your_key"Dev server won't start
# Make sure SDK is installed
pnpm add @browserbasehq/sdk-functions
# Or use npx
npx @browserbasehq/sdk-functions dev index.tsFunction times out
Max execution time is 15 minutes
Add specific timeouts to page operations
Use
waitForSelectorinstead of sleep
Can't connect to browser
Check
session.connectUrlis being used correctlyEnsure you're using
chromium.connectOverCDP()notchromium.launch()
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Declares allowed tools, Needs network access, Needs an API key, Needs Node.js
The author says: Requires the browse CLI (`npm install -g browse`), Node.js 18+ with pnpm or npm, and BROWSERBASE_API_KEY.
Security
What our scanner noticed· Low risk
- Instructions that use the network
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Browserbase
- Publisher
- Browserbase (Official)
- Source
- browserbase/skills · skills/functions · commit 6811ca3
- Licence
- MIT License (redistribution allowed)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Browserbase or Browserbase.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download functions.zip