Loading...
Loading...
Deploy serverless browser automation as cloud functions using Browserbase. Use when the user wants to deploy browser automation to run on a schedule or cron, create a webhook endpoint for browser tasks, run automation in the cloud instead of locally, or asks about Browserbase Functions.
npx skill4agent add team2027/browserbase-skills functionsbrowseexport BROWSERBASE_API_KEY="your_api_key"browse functions init my-function
cd my-functionmy-function/
├── package.json
├── index.ts # Your function code
└── .env # Add credentials hereecho "BROWSERBASE_API_KEY=$BROWSERBASE_API_KEY" >> .envpnpm installimport { 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 };
});context.session.connectUrlcontext.paramsbrowse functions dev index.tshttp://127.0.0.1:14113curl -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"}}'console.log()browse functions publish index.tsFunction published successfully
Build ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Function ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx| Command | Description |
|---|---|
| Create new project |
| Start local dev server |
| Deploy to Browserbase |