Vibe coding with Nutrient Web SDK

TL;DR

Use AI‑powered code generation tools such as Claude or GitHub Copilot to embed Nutrient’s zero‑install PDF viewer in minutes.

AI code assistants can accelerate the integration of advanced PDF capabilities into web applications. This guide explains how to prompt a large language model (LLM) to:

  • Embed Nutrient Web SDK viewer to render, annotate, and edit PDFs directly in the browser.
  • Customize the viewer’s user interface (UI) and behavior with minimal human-written code.

What is vibe coding?

Vibe coding involves guiding an LLM to generate or refactor code in real time. You can do this within:

LLMs can make mistakes, especially during initial use. As you improve your prompts, the output will also improve. Use the example prompt in this guide as a starting point.

Key capabilities of the Nutrient Web SDK viewer

How vibe coding works with the Nutrient Web SDK viewer

  1. Sign up — Start with a free trial. Note that PDFs rendered using the free trial include a watermark. For production use, sign up to create an account on Nutrient Portal(opens in a new tab) and grab your license key.

  2. Teach the LLM — Follow the steps below to provide context and documentation to the language model:

  3. Prime the prompt — Use the template below to set up your initial prompt:

    ## Role
    You are a senior frontend developer.
    ## Instructions
    Use the documentation from these URLs: [Nutrient Web SDK top-level guide](https://www.nutrient.io/guides/web/), [API reference](https://www.nutrient.io/api/web/), and [getting started guides](https://www.nutrient.io/sdk/web/getting-started/). Read and crawl them thoroughly to understand available classes and methods.
    Treat `PSPDFKit.` and `NutrientViewer.` as interchangeable.
    ## Task
    1. Create a minimal React + Vite application (or another framework if preferred).
    2. Integrate Nutrient Web SDK using the documentation provided. If a license key isn't available, use an empty string.
    > Pro tip: Use the [Nutrient CDN link](https://cdn.cloud.pspdfkit.com/[email protected]/nutrient-viewer.js) to include SDK files and assets.
    3. Render a [sample PDF file](https://demo-files.nutrient.io/quick-start.pdf) in the browser on localhost.

Troubleshooting

If the Agent omits an import or uses an incorrect method name, do the following:

  • Copy the relevant code snippet from the official guides.
  • Share the snippet or a screenshot of the snippet with the Agent.
  • Ask the Agent to identify and correct the error based on the official documentation.

Prompts for viewer customization

TaskOne-line prompt to instruct the LLM
Toggle dark modeAdd a button that switches the viewer between light and dark themes.
Limit toolbarsHide all annotation tools except the highlighter and free text note.
Integrate SDK into a React web appWrap the viewer in a functional React component with properties such as container, initialViewState, customFonts, and editableAnnotationTypes.
Localize UILoad the German language pack (or any of your preferred languages) and default the viewer to it.
Signature captureAdd a Sign button that inserts a hand-drawn signature on the current page.

Next steps

FAQs

Does vibe coding replace reading the documentation?

No. Think of it as accelerated onboarding: The LLM writes boilerplate, while you keep the documentation open for deeper options.

Do I need a backend?

Not for viewing and client‑side editing. Everything runs inside the user’s browser.

Can I use TypeScript?

Yes. Just tweak your prompt to use TypeScript as framework of choice.