NUXT INTEGRATION

Capture Nuxt pages from a secure server route or worker

Call Snapshot Site from Nitro server code, not a public component. Resolve an approved route, define hydration readiness, validate the result, and return an application-owned asset record.

Nitro server
Private API call
Hydrated pages
Browser-rendered state
Storage
Controlled results
Install:server/api/capture.post.ts
Auth:SNAPSHOT_SITE_API_KEY
Get started for free
Nuxt screenshot workflow
Snapshot Site themed Nuxt screenshot API illustration
Good fits
Nuxt applications generating page previews
Content sites archiving published routes
Server jobs capturing responsive release evidence
Teams avoiding browser binaries in Nitro deployments

Keep capture infrastructure on the Nuxt server boundary

A Vue component may trigger the job, but provider credentials, destination validation, storage, and normalized errors belong in server code.

1

Caller authorization

Authenticate the application user before allowing work that consumes quota or creates an artifact.

2

Route resolution

Prefer an internal page identifier that the server maps to an approved URL.

3

Hydration readiness

Wait for the content, islands, fonts, and media that define the intended state.

4

Result ownership

Validate and import the artifact before exposing a stable application URL.

Implementation workflow

Create a Nuxt capture endpoint

1

Store the API key in private runtime configuration

2

Accept and authorize a known page identifier

3

Call Snapshot Site from a Nitro event handler

4

Persist request context and return a controlled result

Nuxt screenshot API example

TypeScript

Capture from a Nitro server route

The public client never receives the provider key, and the server resolves a known page path.

export default defineEventHandler(async (event) => {
  const { pageId } = await readBody(event);

  const pages = {
    pricing: "https://example.com/pricing",
    docs: "https://example.com/docs",
  };
  const url = pages[pageId];
  if (!url) {
    throw createError({ statusCode: 400, statusMessage: "Unknown page" });
  }

  const config = useRuntimeConfig(event);
  return await $fetch(
    "https://api.prod.ss.snapshot-site.com/api/v1/screenshot",
    {
      method: "POST",
      headers: {
        "x-snapshotsiteapi-key": config.snapshotSiteApiKey,
      },
      body: {
        url,
        format: "webp",
        width: 1440,
        height: 900,
        fullSize: true,
        hideCookie: true,
      },
    },
  );
});

Nuxt makes the trust boundary explicit

Nitro server routes provide a natural place for screenshot requests. They can authenticate the caller, resolve a product page ID into a URL, load the provider key from private configuration, and normalize the response. A client component only starts the application job and displays its status.

This separation prevents secret exposure and makes destination policy testable. It also keeps rendering options out of multiple UI components.

Capture the hydrated state deliberately

A Nuxt page can combine server rendering, client hydration, lazy components, fonts, images, and data requests. Initial HTML may look complete while a chart or product section is still changing. Define the visual element that marks readiness and test both fast and slow data.

For previews, use an authorized deployed URL. Snapshot Site does not expose an interactive session for navigating a login flow, so private pages need a purpose-built short-lived access design or browser automation.

Move variable work out of request paths

A small preview can run synchronously when platform limits permit. Batches, scheduled jobs, and retryable work are better placed in a queue or external worker. Give every job a durable identifier and make storage idempotent.

Keep the page ID, resolved destination, deployment, viewport, readiness, format, and capture time with the output. The authentication guide covers credential handling, while error handling helps define stable job states.

Screenshot API for Nuxt FAQ

Can I call Snapshot Site from a Nuxt client component?

Do not expose the private API key in browser code. Call an authenticated Nitro endpoint or another trusted backend.

Where should the Nuxt API key be configured?

Use private runtime configuration or deployment secret management, and confirm the value is not included in public runtime config.

Will hydrated Vue content appear?

The managed browser executes JavaScript. Define readiness around meaningful data, images, fonts, and client components.

Can Nuxt capture localhost?

A hosted renderer cannot reach a local development server by default. Use an authorized preview deployment or local browser tooling.

Should the endpoint accept arbitrary URLs?

Prefer page IDs resolved by the server. If raw URLs are required, enforce strict protocol and destination policy.

Can capture run in a Nuxt serverless deployment?

Yes when the runtime can make the outbound HTTPS request and its execution limits suit the job. Use a queue for larger workloads.

How should errors reach the client?

Map provider, validation, storage, and authorization failures into stable application states without leaking credentials or private URLs.

What should be saved with the artifact?

Keep page identity, deployment, viewport, format, readiness settings, capture time, and application authorization context.

Add one secure Nuxt capture route

Start with a known deployed page and server-owned destination mapping before accepting broader capture work.