browserbase/functions

Browserbase を使用してサーバーレスブラウザ自動化をクラウド関数としてデプロイします。スケジュールや cron で実行するブラウザ自動化のデプロイ、ブラウザタスク用の Webhook エンドポイントの作成、ローカルではなくクラウドでの自動化実行、または Browserbase Functions に関する質問がある場合に使用します。

functions とは?

このスキルは、Browserbase プラットフォーム上でサーバーレスのブラウザ自動化関数(Browserbase Functions)をデプロイするための機能を提供します。開発者は、スケジュール実行(cron)や Webhook トリガーを用いたブラウザタスクを、クラウド上で手軽に実行できるようになります。主な利点は、インフラ管理をすることなく、`browserbase` SDK と Playwright を使用して記述された自動化スクリプトを、サーバーレス関数として即座にデプロイできる点です。このスキルは、Playwright ベースのブラウザ自動化プロジェクトにおいて、ローカル実行からクラウド実行への移行、定期的なタスクの自動化、外部サービスからのイベント駆動型ブラウザ操作を実現したい場合に特に有効です。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/browserbase/skills/tree/main/skills/functions

Installed? Explore more 生産性&コラボレーション skills: steipete/gemini, steipete/gh-issues, steipete/skill-creator · View all 6 →

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

functions は何をしますか?

Browserbase を使用してサーバーレスブラウザ自動化をクラウド関数としてデプロイします。ユーザーがスケジュールまたは cron で実行するブラウザ自動化のデプロイ、ブラウザタスク用の Webhook エンドポイントの作成、ローカルではなくクラウドでの自動化の実行、または Browserbase Functions について質問した場合に使用します。

概要

Browserbase Functions を使用すると、インフラストラクチャを管理することなく、ブラウザ自動化タスクをサーバーレス関数としてデプロイできます。これらの関数は、以下によってトリガーできます。

  • スケジュール (cron) - 定期的なジョブの実行
  • Webhook - 外部イベントへの応答
  • API 呼び出し - オンデマンド実行

前提条件

始める前に、以下が必要です。

  • Browserbase アカウント
  • BROWSERBASE_API_KEY と BROWSERBASE_PROJECT_ID が設定された環境
  • Node.js 18 以降

インストール

npm install @browserbasehq/sdk playwright

使用法

1. 関数の作成

ブラウザ自動化を実行する関数を作成します:

import { Browserbase } from '@browserbasehq/sdk';
import { chromium } from 'playwright';

export default async function handler(event, context) {
  const bb = new Browserbase({
    apiKey: process.env.BROWSERBASE_API_KEY,
    projectId: process.env.BROWSERBASE_PROJECT_ID,
  });

  // Browserbase セッションを作成
  const session = await bb.sessions.create({
    projectId: process.env.BROWSERBASE_PROJECT_ID,
  });

  // Playwright でブラウザに接続
  const browser = await chromium.connectOverCDP(session.debuggerUrl);
  const page = await browser.newPage();

  await page.goto('https://example.com');
  const title = await page.title();

  await browser.close();
  await session.end();

  return {
    statusCode: 200,
    body: JSON.stringify({ title }),
  };
}

2. 関数のデプロイ

browserbase CLI を使用して関数をデプロイします:

npx browserbase deploy

CLI により、関数名とトリガータイプ(cron スケジュールまたは Webhook)の設定を求められます。

3. トリガーの設定

Cron スケジュール

定期的な実行のために cron 式を指定します:

# browserbase.yaml
triggers:
  - type: cron
    schedule: "0 9 * * 1-5" # 平日の午前 9 時

Webhook

Webhook エンドポイントを作成します:

# browserbase.yaml
triggers:
  - type: webhook
    path: /my-hook

4. 環境変数

関数で安全な方法で機密データにアクセスするには、環境変数を使用します:

browserbase secrets set MY_API_KEY=my-secret-key

ベストプラクティス

  • エラーハンドリング: 関数内で適切なエラーハンドリングを実装します。
  • ログ記録: デバッグのために console.log を使用します。
  • タイムアウト: 関数のデフォルトタイムアウトは 5 分です。より長いタスクの場合は、browserbase.yaml で調整します。
  • コスト管理: 1 秒あたりのセッション料金が発生します。セッションが不要になったら必ず終了してください。

制限事項

  • サポートされているランタイム: Node.js 18 以降
  • 最大関数実行時間: 15 分
  • 関数あたりの最大メモリ: 1 GB
  • 対応ブラウザ: Chromium (Playwright 経由)

例

その他の例については、Browserbase Functions のドキュメント を参照してください。

トラブルシューティング

  • 接続エラー: BROWSERBASE_API_KEY と BROWSERBASE_PROJECT_ID が正しく設定されていることを確認します。
  • タイムアウトエラー: 関数のタイムアウト設定を増やすか、ロジックを最適化します。
  • デプロイエラー: Node.js バージョンが 18 以降であることを確認し、すべての依存関係がインストールされていることを確認します。

Individual skills in this repo

This repo contains 10 individual skills — each has its own dedicated page.

browserbase/autobrowse

Self-improving browser automation via the auto-research loop. Iteratively runs a browsing task, reads the trace, and improves the navigation skill (strategy.md) until it reliably passes. Supports parallel runs across multiple tasks using sub-agents. Use when you want to build or improve browser automation skills for specific website tasks.

browserbase/browser

Automate web browser interactions using natural language via CLI commands. Use when the user asks to browse websites, navigate web pages, extract data from websites, take screenshots, fill forms, click buttons, or interact with web applications. Supports remote Browserbase sessions with Browserbase Identity, Verified browsers, automatic CAPTCHA solving, and residential proxies — ideal for protected websites and JavaScript-heavy pages.

browserbase/browserbase-cli

Use the Browserbase CLI (`browse`) for Browserbase Functions and platform API workflows. Use when the user asks to run `browse`, deploy or invoke functions, manage sessions, projects, contexts, or extensions, fetch a page through the Browserbase Fetch API, search the web through the Browserbase Search API, or scaffold starter templates. Prefer the Browser skill for interactive browsing; use the top-level `browse` driver commands (`browse open`, `browse get`, etc.) only when the user explicitly wants the CLI path.

browserbase/browser-to-api

Turn a website's observable HTTP traffic into a best-effort OpenAPI 3.1 spec by analyzing a `browser-trace` capture. Use when the user wants to discover/extract API endpoints from a browser session, build an OpenAPI doc from network traffic, or document a third-party site's XHR/fetch surface for client integration.

browserbase/browser-trace

Capture a full DevTools-protocol trace of any browser automation — CDP firehose, screenshots, and DOM dumps — then bisect the stream into per-page searchable buckets. Use when the user wants to debug a failed run, audit network/console/DOM activity, attach a trace to an in-progress session, or feed structured per-page summaries back into an agent loop so its next iteration learns from the last one.

browserbase/cookie-sync

Sync cookies from local Chrome to a Browserbase persistent context so the browse CLI can access authenticated sites. Use when the user wants to browse as themselves, sync cookies, or log into sites via Browserbase.

browserbase/event-prospecting

Event prospecting skill. Takes a conference / event speakers URL, extracts the people, filters their companies against the user's ICP, then deep-researches only the speakers at ICP-fit companies. Outputs a person-first HTML report where each card answers "why should the AE talk to this person?" with all public links and a one-click DM opener. Use when the user wants to: (1) find leads at a specific conference, (2) prep for an event, (3) research event speakers, (4) build a target list from a sponsor/exhibitor page, (5) scrape conference speakers and rank by ICP fit. Triggers: "find leads at {event}", "research speakers at", "prospect this conference", "stripe sessions leads", "ai engineer summit prospects", "event prospecting", "scrape conference speakers", "who should I meet at".

browserbase/fetch

Use this skill when the user wants to retrieve a URL without a full browser session: fetch HTML or JSON from static pages, inspect status codes or headers, follow redirects, or get page source for simple scraping. Prefer it over a browser when JavaScript rendering and page interaction are not needed. Supports proxies and redirect control.

browserbase/safe-browser

Build local constrained-browser agents with a safe_browser tool that owns CDP, enforces a domain allowlist with Fetch interception, and lets a runtime Claude Agent SDK agent complete browsing tasks without raw browser, shell, or CDP access. Use when the user wants an agent to browse or scrape while staying on approved domains, demo blocked off-domain navigation, or generate a safe browser client.

browserbase/ui-test

AI-powered adversarial UI testing via the browse CLI. Analyzes git diffs to test only what changed, or explores the full app to find bugs. Tests functional correctness, accessibility, responsive layout, and UX heuristics. Use when the user asks to test UI changes, QA a pull request, audit accessibility, or run exploratory testing. Supports local browser (localhost) and remote Browserbase (deployed sites).

関連スキル