> ## Documentation Index
> Fetch the complete documentation index at: https://docs.doczilla.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Capture mobile and desktop screenshots

> Compare two breakpoints of the same page and control image resolution.

Render the same page at two viewport widths to see how its layout responds. The CSS viewport controls breakpoints. The device scale factor controls how many output pixels represent each CSS pixel.

## Capture both layouts

Install the [Doczilla Node SDK](https://docs.doczilla.app/libraries/nodejs.md) with `npm install @doczilla/node`. Set `DOCZILLA_API_KEY` and run `node capture-breakpoints.mjs` alongside the HTML file.

```javascript capture-breakpoints.mjs theme={null}
import { readFile, writeFile } from 'node:fs/promises'
import Doczilla, { ScreenshotOptions } from '@doczilla/node'

const apiKey = process.env.DOCZILLA_API_KEY
if (!apiKey) {
  throw new Error('Set DOCZILLA_API_KEY')
}

const doczilla = new Doczilla(apiKey)

const html = await readFile(new URL('./responsive-page.html', import.meta.url), 'utf8')
const viewports = {
  desktop: {
    width: 1280,
    height: 720,
    deviceScaleFactor: 1
  },
  mobile: {
    width: 390,
    height: 844,
    deviceScaleFactor: 2
  }
}

for (const [name, viewport] of Object.entries(viewports)) {
  const image = await doczilla.screenshot.direct({
    page: { html },
    screenshot: {
      type: ScreenshotOptions.type.PNG,
      viewport,
      fullPage: false
    }
  })

  await writeFile(`${name}.png`, image)
}
```

## HTML

Save the HTML below as `responsive-page.html`, or use a publicly reachable page by passing `{ url: 'https://your-site.example/' }` as the request's `page`.

> [accordion] Responsive page HTML
>
> <Snippet file="code-group/responsive-screenshots-html.md" />

## Output

The desktop image is 1280 × 720 pixels. The mobile image is 780 × 1688 pixels, while its CSS viewport is still 390 pixels wide.

![Desktop trail guide with three route cards in a row](https://mintcdn.com/doczilla/Teqhl5ABLAafgT50/images/examples/responsive-desktop.png?fit=max\&auto=format\&n=Teqhl5ABLAafgT50\&q=85\&s=f68715a81d4dd65c9db1ddd11472611a)

Desktop · 1280 CSS pixels wide

![Mobile trail guide with the same route cards stacked vertically](https://mintcdn.com/doczilla/Teqhl5ABLAafgT50/images/examples/responsive-mobile.png?fit=max\&auto=format\&n=Teqhl5ABLAafgT50\&q=85\&s=95d3d814dae98339fee227526ec88fd7)

Mobile · 390 CSS pixels wide

Set `fullPage: true` when you need content below the fold. Keep it off when comparing what someone sees before scrolling. Increase `deviceScaleFactor` for sharper images at the same breakpoint, with a larger output file as a trade-off. See [Screenshot options](https://docs.doczilla.app/api-reference/screenshot-options.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.