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

# clipboard

> Read, write, and dispatch clipboard operations in the browser

Access `BrowserClipboard` from the browser context. Clipboard operations target the active page unless you provide another page.

<Tabs>
  <Tab title="TypeScript">
    ## Quick start

    ```typescript theme={null}
    const clipboard = browser.context.clipboard;
    await clipboard.writeText("Hello");
    ```

    ## readText()

    Read plain text from the browser clipboard.

    ```typescript theme={null}
    const text = await browser.context.clipboard.readText();
    ```

    <ParamField path="options" type="ClipboardOptions" optional>
      Options that select a target page and configure the operation.

      <ParamField path="options.page" type="Page" optional>
        The page to target. Defaults to the active page.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="Promise<string>">
      The clipboard text.
    </ResponseField>

    ## writeText()

    Write plain text to the browser clipboard.

    ```typescript theme={null}
    await browser.context.clipboard.writeText("Hello");
    ```

    <ParamField path="text" type="string">
      The plain text to write.
    </ParamField>

    <ParamField path="options" type="ClipboardOptions" optional>
      Options that select a target page and configure the operation.

      <ParamField path="options.page" type="Page" optional>
        The page to target. Defaults to the active page.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="Promise<void>">
      Resolves after the clipboard operation completes.
    </ResponseField>

    ## clear()

    Clear the browser clipboard.

    ```typescript theme={null}
    await browser.context.clipboard.clear();
    ```

    <ParamField path="options" type="ClipboardOptions" optional>
      Options that select a target page and configure the operation.

      <ParamField path="options.page" type="Page" optional>
        The page to target. Defaults to the active page.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="Promise<void>">
      Resolves after the clipboard operation completes.
    </ResponseField>

    ## paste()

    Paste the clipboard contents into the active element.

    ```typescript theme={null}
    await browser.context.clipboard.paste();
    ```

    <ParamField path="options" type="ClipboardPasteOptions" optional>
      Options that select a target page and configure the operation.

      <ParamField path="options.page" type="Page" optional>
        The page to target. Defaults to the active page.
      </ParamField>

      <ParamField path="options.shortcut" type="'ControlOrMeta+V' | 'Meta+V' | 'Control+V'" optional>
        The keyboard shortcut to dispatch.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="Promise<void>">
      Resolves after the clipboard operation completes.
    </ResponseField>

    ## copy()

    Copy the current selection to the browser clipboard.

    ```typescript theme={null}
    await browser.context.clipboard.copy();
    ```

    <ParamField path="options" type="ClipboardOptions" optional>
      Options that select a target page and configure the operation.

      <ParamField path="options.page" type="Page" optional>
        The page to target. Defaults to the active page.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="Promise<void>">
      Resolves after the clipboard operation completes.
    </ResponseField>

    ## cut()

    Cut the current selection to the browser clipboard.

    ```typescript theme={null}
    await browser.context.clipboard.cut();
    ```

    <ParamField path="options" type="ClipboardOptions" optional>
      Options that select a target page and configure the operation.

      <ParamField path="options.page" type="Page" optional>
        The page to target. Defaults to the active page.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="Promise<void>">
      Resolves after the clipboard operation completes.
    </ResponseField>
  </Tab>

  <Tab title="Python">
    ## Quick start

    ```python theme={null}
    clipboard = browser.context.clipboard
    await clipboard.write_text("Hello")
    ```

    ## read\_text()

    Read plain text from the browser clipboard.

    ```python theme={null}
    text = await browser.context.clipboard.read_text()
    ```

    <ParamField path="page" type="Page | None" optional>
      The page to target. Defaults to the active page.
    </ParamField>

    <ResponseField name="result" type="str">
      The clipboard text.
    </ResponseField>

    ## write\_text()

    Write plain text to the browser clipboard.

    ```python theme={null}
    await browser.context.clipboard.write_text("Hello")
    ```

    <ParamField path="text" type="str">
      The plain text to write.
    </ParamField>

    <ParamField path="page" type="Page | None" optional>
      The page to target. Defaults to the active page.
    </ParamField>

    <ResponseField name="result" type="None">
      Resolves after the clipboard operation completes.
    </ResponseField>

    ## clear()

    Clear the browser clipboard.

    ```python theme={null}
    await browser.context.clipboard.clear()
    ```

    <ParamField path="page" type="Page | None" optional>
      The page to target. Defaults to the active page.
    </ParamField>

    <ResponseField name="result" type="None">
      Resolves after the clipboard operation completes.
    </ResponseField>

    ## paste()

    Paste the clipboard contents into the active element.

    ```python theme={null}
    await browser.context.clipboard.paste()
    ```

    <ParamField path="page" type="Page | None" optional>
      The page to target. Defaults to the active page.
    </ParamField>

    <ParamField path="shortcut" type="Literal['ControlOrMeta+V', 'Meta+V', 'Control+V']" optional>
      The keyboard shortcut used to paste.
    </ParamField>

    <ResponseField name="result" type="None">
      Resolves after the clipboard operation completes.
    </ResponseField>

    ## copy()

    Copy the current selection to the browser clipboard.

    ```python theme={null}
    await browser.context.clipboard.copy()
    ```

    <ParamField path="page" type="Page | None" optional>
      The page to target. Defaults to the active page.
    </ParamField>

    <ResponseField name="result" type="None">
      Resolves after the clipboard operation completes.
    </ResponseField>

    ## cut()

    Cut the current selection to the browser clipboard.

    ```python theme={null}
    await browser.context.clipboard.cut()
    ```

    <ParamField path="page" type="Page | None" optional>
      The page to target. Defaults to the active page.
    </ParamField>

    <ResponseField name="result" type="None">
      Resolves after the clipboard operation completes.
    </ResponseField>
  </Tab>

  <Tab title="Go">
    ## Quick start

    ```go theme={null}
    clipboard := browser.Context().Clipboard()
    if err := clipboard.WriteText(ctx, "Hello", nil); err != nil {
        return err
    }
    ```

    Every method takes a `context.Context` first. Methods with options accept a pointer options struct; pass `nil` for defaults.

    ## ReadText()

    Read plain text from the browser clipboard.

    ```go theme={null}
    text, err := browser.Context().Clipboard().ReadText(ctx, nil)
    if err != nil {
        return err
    }
    fmt.Println(text)
    ```

    <ParamField path="options" type="*ClipboardOptions" optional>
      Options that select a target page. Pass `nil` to use the active page.

      <ParamField path="options.Page" type="*Page" optional>
        The page to target. Defaults to the active page.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="(string, error)">
      The clipboard text and any operation error.
    </ResponseField>

    ## WriteText()

    Write plain text to the browser clipboard.

    ```go theme={null}
    if err := browser.Context().Clipboard().WriteText(ctx, "Hello", nil); err != nil {
        return err
    }
    ```

    <ParamField path="text" type="string">
      The plain text to write.
    </ParamField>

    <ParamField path="options" type="*ClipboardOptions" optional>
      Options that select a target page. Pass `nil` to use the active page.

      <ParamField path="options.Page" type="*Page" optional>
        The page to target. Defaults to the active page.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="error">
      Returns `nil` after the clipboard operation completes.
    </ResponseField>

    ## Clear()

    Clear the browser clipboard.

    ```go theme={null}
    if err := browser.Context().Clipboard().Clear(ctx, nil); err != nil {
        return err
    }
    ```

    <ParamField path="options" type="*ClipboardOptions" optional>
      Options that select a target page. Pass `nil` to use the active page.

      <ParamField path="options.Page" type="*Page" optional>
        The page to target. Defaults to the active page.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="error">
      Returns `nil` after the clipboard operation completes.
    </ResponseField>

    ## Paste()

    Paste the clipboard contents into the active element.

    ```go theme={null}
    if err := browser.Context().Clipboard().Paste(ctx, nil); err != nil {
        return err
    }
    ```

    <ParamField path="options" type="*ClipboardPasteOptions" optional>
      Options that select a target page and configure the operation. Pass `nil` for defaults.

      <ParamField path="options.Page" type="*Page" optional>
        The page to target. Defaults to the active page.
      </ParamField>

      <ParamField path="options.Shortcut" type="*ContextClipboardPasteParamsShortcut" optional>
        The keyboard shortcut to dispatch: `ContextClipboardPasteParamsShortcutControlOrMetaV`, `ContextClipboardPasteParamsShortcutMetaV`, or `ContextClipboardPasteParamsShortcutControlV`.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="error">
      Returns `nil` after the clipboard operation completes.
    </ResponseField>

    ## Copy()

    Copy the current selection to the browser clipboard.

    ```go theme={null}
    if err := browser.Context().Clipboard().Copy(ctx, nil); err != nil {
        return err
    }
    ```

    <ParamField path="options" type="*ClipboardOptions" optional>
      Options that select a target page. Pass `nil` to use the active page.

      <ParamField path="options.Page" type="*Page" optional>
        The page to target. Defaults to the active page.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="error">
      Returns `nil` after the clipboard operation completes.
    </ResponseField>

    ## Cut()

    Cut the current selection to the browser clipboard.

    ```go theme={null}
    if err := browser.Context().Clipboard().Cut(ctx, nil); err != nil {
        return err
    }
    ```

    <ParamField path="options" type="*ClipboardOptions" optional>
      Options that select a target page. Pass `nil` to use the active page.

      <ParamField path="options.Page" type="*Page" optional>
        The page to target. Defaults to the active page.
      </ParamField>
    </ParamField>

    <ResponseField name="result" type="error">
      Returns `nil` after the clipboard operation completes.
    </ResponseField>
  </Tab>
</Tabs>
