Skip to main content
You can publish a Function from a local TypeScript project or from the Browserbase Playground. Both paths create a Function version that you invoke through the API.
Functions are currently only available in the us-west-2 region.

Deploy from the CLI

Use the CLI when you want version control, custom dependencies, or local editor tooling. If you don’t have a local project yet, follow the Functions quickstart.
1

Define the Function in your entrypoint

Node.js
2

Publish the entrypoint

The command builds the Function and prints its Function ID. Save that ID for invoke.
Functions don’t support pnpm workspaces. Keep pnpm-lock.yaml or package-lock.json in the Function project directory, not only at a workspace root.
Publishing again with the same Function name creates a new version. Callers keep using the same Function ID. To ship several Functions from one entrypoint, see publish multiple Functions.

Deploy from the Playground

The Playground lets you write and publish a Function without a local project. Test Stagehand or Playwright code in a live browser, define input parameters, then publish. Deploying Functions from the Playground
1

Open the Playground

Open the Browserbase dashboard, then select Playground.
2

Write the browser script

The editor starts with a Stagehand template. Write the browser logic that the Function will run:
Playground
The Playground provides connectUrl, sessionId, apiKey, and z as globals. Use Convert to Stagehand to convert a Playwright script.
The Playground does not compile TypeScript. Your code runs as JavaScript, so type annotations, interfaces, and casting will throw a SyntaxError. When you publish, the Playground puts your script into an index.ts file.
3

Test the script

Select Run. The Playground creates a browser session, runs the script, displays its output, and opens a live browser view.Use the console output and live view to fix the script before you publish it.
4

Define Function parameters

Open Deploy, then add inputs under Function Parameters:Adding Function parametersEach parameter has a name and an optional default value. The published Function receives the values through params:
Playground
Run doesn’t populate params. Use a literal value while you test, then replace it with params.<name> before you publish. You can define up to eight parameters.
5

Publish the Function

In the Deploy panel:
  1. Enter a Function name.
  2. Select Deploy as Function. Publishing a Function
After the build completes, the Playground shows an invoke command and a link to the Function details.
Publishing the same Function name creates a new version of the existing Function. Move to a local project and deploy from the CLI when you need version control, multiple files, custom dependencies, or local editor tooling.

After you deploy

Open Functions in the dashboard to:
  • Copy the Function ID and invoke command.
  • Review builds, versions, and invocation history.
  • Inspect invocation logs and browser sessions.
  • Delete a Function.

Invoke a Function

Pass parameters and retrieve asynchronous results.

Write a Function

Configure schemas, browser settings, and multiple Functions.