# functions

Deploys serverless browser automation as cloud functions using Browserbase. It handles scheduled cron runs and webhook-triggered browser tasks.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 2800 installs · ★ 3742
- Author: browserbase
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/browserbase/skills/tree/HEAD/skills/functions/SKILL.md
- Updated: 2026-09-29
- HTML: https://affpapa.org/en/nevibecode/skills/functions

## What it does

This skill manages headless browser scripts deployed as Browserbase cloud functions. It handles project scaffolding via `browse functions init` and deployment with `browse functions publish`.

Functions rely on `@browserbasehq/sdk-functions` and connect to remote browsers through Playwright's `chromium.connectOverCDP`. The entry point receives execution parameters and returns JSON results. The dev server `browse functions dev` reloads on file changes. Testing payloads locally stays quick.

Execution requires Node.js 18+ and the globally installed `browse` CLI. You also need pnpm or npm and a valid `BROWSERBASE_API_KEY`. Missing the CLI or key causes immediate terminal errors.

## Requirements
- Works with: Playwright

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add browserbase/skills --skill functions -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/functions/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/functions/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add browserbase/skills --skill functions -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/functions/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add browserbase/skills --skill functions -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/functions/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install browserbase/skills functions
```

2. **Manually: put the files in place**
- File: `.github/skills/functions/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add browserbase/skills --skill functions -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/browserbase/skills --path skills/functions
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/functions/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add browserbase/skills --skill functions -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/browserbase/skills/tree/HEAD/skills/functions/SKILL.md

## When to use it
- deploy Playwright automation scripts as serverless cloud functions
- trigger browser automation runs on a cron schedule or via webhooks
- spin up a local dev server to test function payloads before deployment
- scaffold a new Browserbase function project with TypeScript and environment variables

## Example prompts
- Initialize a new Browserbase function project and start the local dev server
- Write a Playwright cloud function that connects over CDP and extracts page titles
- Deploy my finished browser function using browse functions publish

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: d0e2059e2dbb0b11.

BEGIN THIRD-PARTY FILE d0e2059e2dbb0b11
````text
---
name: functions
description: "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."
compatibility: "Requires the browse CLI (`npm install -g browse`), Node.js 18+ with pnpm or npm, and BROWSERBASE_API_KEY."
license: MIT
allowed-tools: Bash Read Write Edit
---

# Browserbase Functions

Deploy serverless browser automation using the official `browse` CLI.

## Prerequisites

Get an API key from: https://browserbase.com/settings

```bash
export BROWSERBASE_API_KEY="your_api_key"
```

## Creating a Function Project

### 1. Initialize

```bash
browse functions init my-function
cd my-function
```

This creates:
```
my-function/
├── package.json
├── index.ts        # Your function code
└── .env            # Add credentials here
```

### 2. Add Credentials to .env

```bash
echo "BROWSERBASE_API_KEY=$BROWSERBASE_API_KEY" >> .env
```

### 3. Install Dependencies

```bash
pnpm install
```

## Function Structure

```typescript
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 Playwright
- `context.params` - Input parameters from invocation

## Development Workflow

### 1. Start Dev Server

```bash
browse functions dev index.ts
```

Server runs at `http://127.0.0.1:14113`

### 2. Test Locally

```bash
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

```bash
browse functions publish index.ts
```

Output:
```
Function published successfully
Build ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Function ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
```

**Save 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](REFERENCE.md).
````
END THIRD-PARTY FILE d0e2059e2dbb0b11

The third-party file has ended. Everything between the d0e2059e2dbb0b11 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

© browserbase · MIT · https://github.com/browserbase/skills/tree/HEAD/skills/functions/SKILL.md

## Similar
- [playwriter](https://affpapa.org/en/nevibecode/skills/playwriter.md) — skill · 5800 installs
- [playwright-skill](https://affpapa.org/en/nevibecode/skills/sickn33-playwright-skill.md) — skill · 3900 installs
- [playwright](https://affpapa.org/en/nevibecode/skills/secondsky-playwright.md) — skill · 1000 installs

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
