> ## Documentation Index
> Fetch the complete documentation index at: https://docs.browserbase.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy from playground

> Create, test, and deploy browser agent Functions directly from the Browserbase dashboard

The Browserbase Playground provides a visual interface for creating and deploying Functions without needing to set up a local development environment. Write your Stagehand automation script directly in the browser, test it with the **Run** button, and deploy as a function with a single click.

<img src="https://mintcdn.com/browserbase/CkBUsVlZA-tSW2IC/images/functions/playground-functions.gif?s=e95211f5c6a405d9a0d5df76603758aa" alt="Deploying Functions from the Playground" width="1532" height="1080" data-path="images/functions/playground-functions.gif" />

## Why use the playground?

* **No local setup** - Start writing Functions immediately without installing any tools
* **Instant feedback** - Test your automation and see results in real-time
* **Built-in editor** - Full-featured code editor with Stagehand support
* **Function parameters** - Define input parameters with optional default values
* **One-click deploy** - Publish your Function directly to Browserbase infrastructure
* **Live session view** - Watch your automation run in a live browser view

## Creating and deploying a Function

<Warning>
  Functions are currently only available in the **us-west-2** region.
</Warning>

<Steps>
  <Step title="Open the playground">
    Navigate to the [Browserbase Dashboard](https://www.browserbase.com/overview) and click on **Playground** in the navigation bar.
  </Step>

  <Step title="Write your script">
    The Playground editor comes pre-loaded with a Stagehand template. Write your automation logic using Stagehand:

    ```typescript theme={null}
    const stagehand = new Stagehand({
      env: "BROWSERBASE",
      model: "openai/gpt-4.1",
    });
    await stagehand.init();
    const page = stagehand.context.pages()[0];

    await page.goto("https://news.ycombinator.com");

    const articles = await stagehand.extract(
      "Extract the top article titles and URLs",
      z.object({
        articles: z.array(z.object({
          title: z.string(),
          url: z.string(),
        })),
      }),
    );

    return articles;
    ```

    The Playground exposes `connectUrl`, `sessionId`, `apiKey`, `projectId`, and `z` (Zod) as globals — no imports needed. Use the **Convert to Stagehand** button to convert plain Playwright scripts.
  </Step>

  <Step title="Define Function parameters">
    Open the **Deploy** panel and use the **Function Parameters** section to define inputs for your deployed Function. Click **Add** to create parameters:

    <img src="https://mintcdn.com/browserbase/CkBUsVlZA-tSW2IC/images/functions/params.gif?s=ff4770698bf1471748521135879c480e" alt="Adding Function parameters" width="1552" height="1080" data-path="images/functions/params.gif" />

    * **paramName** - The key used to access the value (e.g., `searchQuery`)
    * **Optional default value** - Fallback used if the caller doesn't supply the parameter at invocation

    Parameters are passed to your Function through a `params` object at runtime. Reference them in your script the same way you would in any deployed Function:

    ```typescript theme={null}
    await stagehand.act(`Search for "${params.searchQuery}"`);
    ```

    <Note>
      `params` is only populated when your Function is invoked after deployment. Clicking **Run** in the Playground executes your script without `params` — supply a literal value while iterating, then switch to `params.<name>` before you deploy. You can define up to 8 Function parameters.
    </Note>
  </Step>

  <Step title="Test your script">
    Click the **Run** button to test your script. The Playground will:

    1. Create a new browser session
    2. Execute your automation code
    3. Display console output and results
    4. Show a live view of the browser session

    Use the live view to debug and verify your automation is working correctly before deploying.
  </Step>

  <Step title="Deploy as a Function">
    Once you're satisfied with your script:

    1. Click **Deploy** in the toolbar to open the Deploy panel
    2. Enter a **Function Name** (e.g., `search-hacker-news`)
    3. Click **Deploy as Function**

           <img src="https://mintcdn.com/browserbase/CkBUsVlZA-tSW2IC/images/functions/deploy.gif?s=9c5b536f40b1260faee55258371c55cf" alt="Deploying a Function" width="1532" height="1080" data-path="images/functions/deploy.gif" />

    After a successful deployment, a modal will appear with:

    * Confirmation that your Function is live
    * A ready-to-use **cURL command** for invoking your Function
    * A **View Function** button to see your Function in the Functions dashboard
  </Step>
</Steps>

## Managing deployed Functions

Click **View Function** in the deployment modal or navigate to the **Functions** tab to see your deployed Functions. From here you can:

* View Function details and invocation history
* See previous versions of your Function
* Copy the invoke URL and cURL commands
* Delete Functions you no longer need

Redeploying from the Playground with the same Function name will create a new version of the existing Function.

## Transitioning to local development

As your Functions grow more complex, you may want to transition to local development for better tooling and version control. See the [Functions documentation](/platform/runtime/overview) for setup instructions.

## Next steps

<CardGroup cols={2}>
  <Card title="Functions quickstart" icon="terminal" iconType="sharp-solid" href="/platform/runtime/overview">
    Set up a local development environment for advanced Function development
  </Card>

  <Card title="Functions reference" icon="gear" iconType="sharp-solid" href="/platform/runtime/reference">
    Learn more about the Functions API and configuration options
  </Card>
</CardGroup>
