Skip to main content

Try another path without starting over.

page.fork() copies the current page — its HTML, cookies, localStorage and sessionStorage — into a new page. An agent can explore one option on the copy while the original stays exactly where it was.

Explore two paths from one page
const branch = page.fork();   // copy, no network request

branch.click('@4');           // try "Forgot password?"
page.click('@3');             // main path: submit the form

How it works.

  1. Snapshot the state

    Memora captures the page HTML, URL, cookies, localStorage and sessionStorage.

  2. Restore into a new page

    A fresh page is created and the captured state is loaded into it, without fetching the URL again.

  3. Act independently

    Clicks and typing on the copy don’t touch the original. Keep the branch that worked and drop the rest.

What you get.

No extra request

The copy is built from state already in memory, so the site doesn’t see a second visit.

Session comes along

Cookies and web storage are copied too, so a logged-in session stays logged in on the copy.

About 5 ms

Median fork time was 4.9 ms for a test page with 400 interactive elements on a laptop. Larger pages take longer.

Fork from the library or from MCP.

Agents connected through MCP can call the memora_fork tool to open the copy in a new tab.

Example
const page = browser.newPage();
await page.goto('https://shop.example.com/cart');

const tryCoupon = page.fork();
tryCoupon.type('@5', 'WELCOME10');
tryCoupon.click('@6');

// Compare results, then continue on whichever page you prefer.

Common questions.

Does the copy run the page scripts again?
The copy is restored from the captured HTML and storage. Treat it as a snapshot of the page at the moment you forked it.
How fast is it?
In a local test, forking a page with 400 interactive elements took 4.9 ms at the median (2.5–28.4 ms over 20 runs). Time grows with page size.

Put Page forking to work.

The docs walk you through starting the server and connecting your first agent.