Appearance
Usage
Minimal Example: Puppeteer via npm package
This is the canonical quickstart from the official docs. Lightpanda starts its own CDP server internally; Puppeteer connects to it over a local WebSocket.
Create index.js:
javascript
import { lightpanda } from '@lightpanda/browser';
import puppeteer from 'puppeteer-core';
const lpdopts = { host: '127.0.0.1', port: 9222 };
const puppeteeropts = {
browserWSEndpoint: 'ws://' + lpdopts.host + ':' + lpdopts.port
};
(async () => {
const proc = await lightpanda.serve(lpdopts);
const browser = await puppeteer.connect(puppeteeropts);
const page = await browser.createBrowserContext().then(c => c.newPage());
await page.goto('https://example.com');
const title = await page.title();
console.log('Page title:', title);
await browser.disconnect();
proc.kill();
})();Run it:
bash
node index.jsCLI: Fetch and Dump a URL
Use the binary directly to fetch a page and dump its rendered HTML to stdout:
bash
./lightpanda fetch \
--obey-robots \
--dump html \
--log-format pretty \
--log-level info \
https://demo-browser.lightpanda.io/campfire-commerce/CLI: Start CDP Server
Run Lightpanda as a persistent CDP server that any Puppeteer or Playwright script can connect to:
bash
./lightpanda serve \
--obey-robots \
--log-format pretty \
--log-level info \
--host 127.0.0.1 \
--port 9222Then connect from any Puppeteer script with browserWSEndpoint: 'ws://127.0.0.1:9222'.
CLI: Agent Mode
Run a natural-language task directly against a URL:
bash
./lightpanda agent --task "top story on news.ycombinator.com?"Cloud API (Puppeteer)
Replace the local WebSocket endpoint with the Lightpanda cloud endpoint:
javascript
const browser = await puppeteer.connect({
browserWSEndpoint: 'wss://euwest.cloud.lightpanda.io/ws?token=YOUR_TOKEN'
});Requires a cloud API token obtained from https://lightpanda.io.