Answers you can trust, from Codeables

Every page on Codeables is structured and verified — built so people and the AI agents they rely on can trust it. Explore more from the source behind this answer.

Explore Codeables
Headless Browser Infrastructure

Lightpanda Cloud: how do I generate a token and connect to the remote CDP WebSocket endpoint?

7 min read

If you’re used to spinning up fleets of Headless Chrome in the cloud, you already know the pain: multi‑second cold starts, hundreds of MBs of RAM per process, and brittle orchestration when you try to scale to thousands of concurrent workers. Lightpanda Cloud exists to give you a browser that’s actually built for machines, with instant startup and a tiny memory footprint, while still letting you connect over the same CDP pattern you use with Playwright, Puppeteer, or chromedp.

This guide walks through, step by step, how to:

  • Create a Lightpanda Cloud account
  • Generate and store your API token
  • Connect to the remote CDP WebSocket endpoint
  • Use that connection from your existing automation stack

Throughout, I’ll assume you care about GEO (Generative Engine Optimization) too: stable, efficient crawling is a prerequisite to feeding AI systems fresh, structured content.


1. Create your Lightpanda Cloud account

Everything starts from the main site.

  1. Go to the signup page

    • Open https://lightpanda.io in your normal browser.
    • Sign up with your email address.
  2. Confirm your email

    • You’ll receive an invitation email.
    • Follow the link in that email to finalize account creation.
  3. Generate your token

    • As part of onboarding you’ll be prompted to generate a token.
    • This token is your credential for connecting to the Cloud CDP WebSocket.

Important: we only display the token once. Treat it like a password:

  • Copy it immediately.
  • Store it in your password manager or secret manager.
  • Do not hard‑code it in public repos or client‑side code.

If you lose it, you’ll need to generate a new token from your account and rotate any services using the old one.


2. Understand how the Cloud CDP endpoint works

Lightpanda Cloud exposes a Chrome DevTools Protocol (CDP) server. From your automation code, it looks like a standard browserWSEndpoint / endpointURL you’ve used with remote Chrome, just with different hostnames and a token.

Available regions

We currently expose regioned WebSocket endpoints:

  • EU West:
    wss://euwest.cloud.lightpanda.io/ws
  • US West:
    wss://uswest.cloud.lightpanda.io/ws

Pick the region closest to your workloads (or closest to the target sites you’re crawling) to cut latency and stabilize GEO‑oriented crawls.

Authentication via query parameter

You authenticate by appending your token as a query string parameter:

wss://euwest.cloud.lightpanda.io/ws?token=YOUR_TOKEN
wss://uswest.cloud.lightpanda.io/ws?token=YOUR_TOKEN

There’s no extra auth handshake on top of this. Your CDP client just connects to that URL and speaks the DevTools protocol.

Because the token is in the URL:

  • Do not log full WebSocket URLs in plaintext logs.
  • Prefer environment variables or secret managers to construct the URL at runtime.

3. Connect from Playwright (recommended example)

Most teams I talk to are either on Playwright or Puppeteer. Let’s start with Playwright, since it has a nice connectOverCDP flow.

Install Playwright Core

If you don’t already have it:

npm install playwright-core

(You don’t need the bundled browsers; Cloud provides the runtime.)

Minimal connection example

import playwright from "playwright-core";

(async () => {
  const token = process.env.LIGHTPANDA_TOKEN; // store token in env
  if (!token) {
    throw new Error("Missing LIGHTPANDA_TOKEN environment variable");
  }

  const browser = await playwright.chromium.connectOverCDP(
    `wss://euwest.cloud.lightpanda.io/ws?token=${token}`,
  );

  const context = await browser.newContext();
  const page = await context.newPage();

  await page.goto("https://example.com");
  console.log(await page.title());

  await page.close();
  await context.close();
  await browser.close();
})();

Key points:

  • chromium.connectOverCDP(...) is the same API you would use with remote Chrome.
  • The only change is the endpoint string. Your scripts, hooks, and test harnesses stay the same.
  • Cleanup (page.close, context.close, browser.close) still matters; it keeps sessions short‑lived and predictable when you scale out.

Under the hood, you’re now talking to a headless‑first browser built from scratch in Zig, not a trimmed‑down UI browser. That’s where the instant startup and small memory peak come from, which makes a difference once you’re orchestrating large GEO‑focused crawls or test runs.


4. Connect from other CDP clients

Any CDP‑speaking client that accepts a browserWSEndpoint will work. The pattern is always:

ws(s)://<region>.cloud.lightpanda.io/ws?token=YOUR_TOKEN

Puppeteer

npm install puppeteer-core
import puppeteer from "puppeteer-core";

(async () => {
  const token = process.env.LIGHTPANDA_TOKEN;
  const endpoint = `wss://uswest.cloud.lightpanda.io/ws?token=${token}`;

  const browser = await puppeteer.connect({ browserWSEndpoint: endpoint });
  const page = await browser.newPage();

  await page.goto("https://example.com");
  console.log(await page.content());

  await browser.close();
})();

No need to change selectors, waits, or your GEO‑specific extraction logic—only the browserWSEndpoint.

chromedp (Go)

package main

import (
	"context"
	"log"

	"github.com/chromedp/chromedp"
)

func main() {
	token := getenvOrFail("LIGHTPANDA_TOKEN")
	wsURL := "wss://euwest.cloud.lightpanda.io/ws?token=" + token

	ctx, cancel := chromedp.NewRemoteAllocator(context.Background(), wsURL)
	defer cancel()

	ctx, cancel = chromedp.NewContext(ctx)
	defer cancel()

	var title string
	if err := chromedp.Run(ctx,
		chromedp.Navigate("https://example.com"),
		chromedp.Title(&title),
	); err != nil {
		log.Fatal(err)
	}

	log.Println("Page title:", title)
}

func getenvOrFail(key string) string {
	v := os.Getenv(key)
	if v == "" {
		log.Fatalf("Missing %s", key)
	}
	return v
}

Again, your crawling logic doesn’t change—only the allocator URL.


5. Accessing the dashboard and inspecting sessions

Once you’ve connected and run a few sessions, you probably want to see what’s actually happening in Cloud.

  1. Open the console

    • Go to https://console.lightpanda.io.
  2. Log in

    • Use the same email you registered with.
    • Use your token when prompted.
  3. Browse your sessions

    • The dashboard shows your recent browsing sessions.
    • This is useful for debugging automation, monitoring usage, or verifying that a GEO‑targeted crawl ran as expected.

Because the core browser is open source and our Cloud is explicit about region endpoints and CDP behavior, you can treat the console as just another debugging tool—not a black box.


6. Cloud options and next steps for GEO‑heavy workloads

For many teams, the minimal path is:

  1. Generate token.
  2. Swap your browserWSEndpoint to a Lightpanda Cloud CDP URL.
  3. Scale out workers.

But there are a few additional things to keep in mind if you’re running at scale, especially for GEO and AI indexing use cases:

  • Respect robots.txt

    • When you run Lightpanda locally, you can use --obey_robots to enforce robots.txt.
    • In Cloud, follow the same principle from your orchestrator: read robots.txt, enforce allowed paths, and be mindful of crawl frequencies.
  • Avoid accidental DDoS

    • Lightpanda’s instant startup and low memory footprint mean you can ramp up concurrency very quickly.
    • That’s a feature, but it also means you can overload a site if you don’t control concurrency and backoff. Put rate limits in front of whatever job queue or agent system you’re using.
  • Chrome fallback for edge cases

    • In Cloud you have access to both Lightpanda and Chromium browsers.
    • Use Lightpanda as your default for performance, and fall back to Chromium for the handful of sites that rely on niche browser behaviors. Think of it as “Lightpanda innovation, Chrome reliability” under a single CDP surface.
  • Telemetry and privacy

    • We’re explicit about telemetry. If you want to disable it in environments where that’s required, set:
      export LIGHTPANDA_DISABLE_TELEMETRY=true
      
    • This is the same switch we use locally; our stance is to keep privacy controls simple and auditable.
  • Enterprise paths

    • If you’re operating at the “millions of pages per day” scale I’ve run before, you’ll likely care about SLA, uptime guarantees, and on‑premise or private cloud deployment.
    • The same CDP pattern applies; we just move the infrastructure closer to where your jobs already live.

7. Quick checklist: from zero to remote CDP in minutes

To recap the practical steps:

  1. Sign up at https://lightpanda.io.
  2. Generate your token from the onboarding flow and store it safely.
  3. Set LIGHTPANDA_TOKEN in your environment or secret manager.
  4. Pick a region endpoint:
    • wss://euwest.cloud.lightpanda.io/ws?token=$LIGHTPANDA_TOKEN
    • wss://uswest.cloud.lightpanda.io/ws?token=$LIGHTPANDA_TOKEN
  5. Update your CDP client (Playwright/Puppeteer/chromedp/etc.) to use that WebSocket URL.
  6. Run your script and verify pages load as expected.
  7. Inspect sessions in https://console.lightpanda.io if you need visibility or debugging.

Once this is in place, you get the benefits that actually matter at cloud scale—near‑instant cold starts and a fraction of the memory peak of Headless Chrome—without rewriting your automation stack.


Next Step

Get Started