Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

How to Go Forward to the Next Page with Puppeteer

Use Puppeteer’s page.goForward() to traverse to the next browser-history entry. Learn its return values, errors, timeout behavior and difference from goto().
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use await page.goForward() to move the current Puppeteer page to its next browser-history entry. It is history traversal, not a command to open a URL you specify.

Call page.goForward()

The method returns a promise for the main resource response, or null when the transition is same-page. It throws if there is no forward entry in the page’s history. [Puppeteer API reference]

As an Amazon Associate I earn from qualifying purchases.

await page.goForward();

For example, if a page navigates from one URL to another and then goes back, calling goForward() can return to the later history entry, provided it remains in the history stack.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Handle the response and missing history entry

Because the call is asynchronous, await it when subsequent code depends on the history transition. If a forward entry may not exist, handle the exception in the way appropriate to your application; Puppeteer documents that the call throws in this case but does not prescribe a specific recovery policy.

try {
  const response = await page.goForward();
  if (response === null) {
    console.log('The history transition was same-page.');
  } else {
    console.log('Returned to a history entry.');
  }
} catch (error) {
  console.error('Could not go forward in page history:', error);
}

A non-null result is the main resource response. Do not treat null as a failed call: the API defines it as the result for same-page navigation. [Puppeteer API reference]

Choose the right navigation method

  • Use page.goForward() to traverse to the next entry in the current page’s browser history.
  • Use page.goBack() to traverse to the previous history entry. [Puppeteer API reference]
  • Use page.goto(url) when you know the destination and want to navigate directly to it, rather than replaying a history entry. [Puppeteer API reference]

For goto(), Puppeteer’s reference says to include a URL scheme such as https://. That method returns the main resource response, including the last redirect response when redirects occur. Navigation to about:blank or to the same URL with a different hash returns null. Those are goto() details, not additional goForward() rules. [Puppeteer API reference]

Set navigation waits and timeouts

goForward(options) accepts optional navigation wait options. If the default navigation timeout is unsuitable, Puppeteer’s page navigation-timeout setting applies to goForward(), as well as goBack(), goto(), reload, setContent() and waitForNavigation(). Consult the API reference for the supported options and current configuration details. [goForward reference] [setDefaultNavigationTimeout reference]

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A timeout means the navigation did not complete within the configured wait period; it does not establish that a forward history entry was absent. Handle navigation timeouts separately from the documented no-entry exception where your application needs to distinguish those cases.

What forward navigation means in a single-page app

Puppeteer defines navigation as a URL change, not only as a new document request. Anchor changes and History API transitions count, so a forward-history transition may be same-page rather than a conventional full-page load. The goForward() contract’s null result covers that same-page case. [Puppeteer FAQ] [Puppeteer API reference]

Browser and version considerations

The method reference linked here is the next documentation, which can change as Puppeteer evolves. Confirm the API and browser configuration against the version installed in your project. Puppeteer’s FAQ says that from v23.0.0 onward it supports Chrome and Firefox; it describes Chrome automation through the Chrome DevTools Protocol by default and WebDriver BiDi as the default for Firefox. These statements do not mean every project is running that version or configuration. [Puppeteer FAQ]

Troubleshooting

  • No forward entry: goForward() throws when the current page has no later history entry. Ensure your workflow first reaches and then leaves the history entry you intend to revisit, or use goto(url) if you already know the destination.
  • Result is null: This is the documented result for same-page navigation, not necessarily an error. URL changes through anchors or the History API can qualify as navigation without a new document response.
  • Navigation wait times out: Check the configured navigation timeout and the wait conditions passed to the method. The page navigation-timeout setting applies to goForward().
  • You need a particular URL, not history: Call goto(url) with a URL that includes its scheme instead of relying on the current history stack.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your goal is a screenshot rather than browser-history automation, ScreenshotNeo takes a screenshot with one GET request. Its API accepts consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads and cache hits cost nothing, and response headers report the page verdict and billing status. It also has an MCP server for AI agents, including Claude, Cursor and other MCP clients.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

cURL example (see the ScreenshotNeo API documentation):

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo includes 1,000 screenshots a month free with no card; paid plans start at $5 for 3,000. Sign up for free.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.