---
title: "JavaScript to create, generate, & add bookmarks in PDFs | Nutrient"
canonical_url: "https://www.nutrient.io/guides/web/features/bookmarks/"
md_url: "https://www.nutrient.io/guides/web/features/bookmarks.md"
last_updated: "2026-05-23T00:08:18.167Z"
description: "With Nutrient Web SDK, it’s possible to create bookmarks both using the sidebar UI and programmatically with JavaScript."
---

# Create bookmarks in PDF using JavaScript

With Nutrient Web SDK, it’s possible to create bookmarks both using the [sidebar UI](https://www.nutrient.io/guides/web/bookmarks/built-in-ui.md) and programmatically with JavaScript. This guide will focus on the programmatic creation of bookmarks.

Here’s how to create a bookmark in JavaScript:

```js

const bookmark = new NutrientViewer.Bookmark({
  name: "test bookmark",
  action: new NutrientViewer.Actions.GoToAction({ pageIndex: 3 })
});

instance.create(bookmark);

```

The example above creates a bookmark with a [`GoToAction`](https://www.nutrient.io/api/web/NutrientViewer.Actions.GoToAction.html), which takes the user to a destination (page 3) in the current document. There are several other actions you can use with bookmarks, such as opening a web link, submitting or resetting a form, or executing a script. These are described in the [PDF actions](https://www.nutrient.io/guides/web/annotations/pdf-actions.md) guide.

## Linking to URIs

Using the [`URIAction`](https://www.nutrient.io/api/web/NutrientViewer.Actions.URIAction.html), you can link to a website from your bookmarks:

```js

const website = new NutrientViewer.Bookmark({
  name: "PSPDFKit website",
  action: new NutrientViewer.Actions.URIAction({
    uri: "https://www.nutrient.io"
  })
});

instance.create(website);

```
---

> Part of [JavaScript PDF bookmark library](/guides/web/bookmarks.md)

## Related pages

- [Detect changes in PDF bookmarks](/guides/web/bookmarks/detect-changes.md)
- [Edit bookmarks in PDFs using JavaScript](/guides/web/bookmarks/edit.md)
- [Remove bookmarks in PDFs using JavaScript](/guides/web/bookmarks/remove.md)
- [PDF bookmarks in our JavaScript PDF viewer](/guides/web/bookmarks/built-in-ui.md)

