Puppeteer
Pass Puppeteer's page as it is: Unstuck opens its own debugging session on it.
npm init -y && npm pkg set type=module
npm install @velmlabs/unstuck puppeteerconst unstuck = new Unstuck({
onLink: ({ url, reason }) => console.log(`\n${reason}. Open this link:\n${url}\n`),
});
// Pass Puppeteer's page as is: the agent waits while a person solves it.
const result = await unstuck.takeover(page!, { reason: 'Please log in', timeoutS: 300 });
console.log(`Takeover ${result.status} after ${result.durationS}s`);Options and Unstuck Cloud work as in the Quickstart. On Cloudflare Browser Rendering (@cloudflare/puppeteer), see Cloudflare Workers.
Let Unstuck notice the check
Or wrap the page once, and a navigation or click that lands on a CAPTCHA brings a person in by itself:
const unstuck = new Unstuck({
onLink: ({ url, reason }) => console.log(`\n${reason}. Open this link:\n${url}\n`),
});
const page = unstuck.wrap(await browser.newPage(), { remember: true });
try {
await page.goto(process.argv[2] ?? 'https://www.google.com/recaptcha/api2/demo');
console.log(`Takeover ${page.unstuck.lastRescue?.status ?? 'not needed'}: now on "${await page.title()}"`);
} catch (e) {
if (!(e instanceof UnstuckRescueError)) throw e;
console.log(`Takeover ${e.status}: ${e.message}`);
}More in Unstuck Browser.
What the person sees
They open the link and see your agent's live page: on this machine by default, or on any phone with Unstuck Cloud. They tap and type straight into it (a Keyboard button opens the phone keyboard), then tap Done. If they can't, Can't solve hands it back with a reason.

The complete file
// Unstuck + Puppeteer: an agent opens a page, asks a human to take over, then carries on.
//
// npm init -y && npm pkg set type=module
// npm install @velmlabs/unstuck puppeteer
// npx tsx index.ts [url]
//
// Add UNSTUCK_API_KEY=uk_live_… to your environment to send the link through Unstuck Cloud.
import puppeteer from 'puppeteer';
import { Unstuck } from '@velmlabs/unstuck';
const browser = await puppeteer.launch();
const [page] = await browser.pages();
await page!.setViewport({ width: 1280, height: 720 });
await page!.goto(process.argv[2] ?? 'https://www.google.com/recaptcha/api2/demo');
// #region snippet
const unstuck = new Unstuck({
onLink: ({ url, reason }) => console.log(`\n${reason}. Open this link:\n${url}\n`),
});
// Pass Puppeteer's page as is: the agent waits while a person solves it.
const result = await unstuck.takeover(page!, { reason: 'Please log in', timeoutS: 300 });
console.log(`Takeover ${result.status} after ${result.durationS}s`);
// #endregion snippet
await unstuck.close();
await browser.close();