Skip to main content
To get started, you first need to create a Grasp container. This will provision a cloud environment with a browser instance ready for you to connect to.

Creating a Container

Here is the basic setup for creating a container.
import { Grasp } from '@getgrasp/sdk';

// Make sure your GRASP_API_KEY is set as an environment variable
const grasp = new Grasp();

const container = await grasp.create();

console.log('Container created with ID:', container.id);
Once the container is created, you can access its CDP endpoint to connect programmatically.

Connecting with CDP

For powerful, programmatic control over the browser, Grasp exposes a Chrome DevTools Protocol (CDP) WebSocket endpoint. This allows you to connect with popular automation libraries like Playwright or Puppeteer.
const wsEndpoint = container.browser.wsEndpoint;
// Example: wss://9223-e8b3b6b2-2b8a-4c6b-a1b3-f1b3b6b2b8a4.grasp.run

Example with Playwright

Here’s a complete example showing how to create a container and then connect to its browser session using Playwright.
import { Grasp } from '@getgrasp/sdk';
import { chromium } from 'playwright';

const grasp = new Grasp();
const container = await grasp.create();

// Connect Playwright to the cloud browser via CDP
const browser = await chromium.connectOverCDP(container.browser.wsEndpoint);

const page = await browser.newPage();
await page.goto('https://www.google.com');
console.log('Page title:', await page.title());

await browser.close();
await container.shutdown();
This enables you to run complex automation scripts, scrape data, or perform tests on the browser instance managed by Grasp.