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

Use Playwright to open the page in a controlled browser, set the preview dimensions and page state, then save a screenshot with page.screenshot(). For a compact preview image, capture the viewport; use fullPage: true only when the image should include the whole scrollable page. The implementation is the same for an Indian SaaS app as for any other app: the right hosting region, data handling and compliance requirements depend on the product, not on Playwright.

Choose the preview image you actually need

Start with the display surface. A link card or thumbnail usually needs a fixed-size viewport capture. A full-page screenshot is much taller and may be awkward to display as a preview. If only one part of the page matters, Playwright can capture a specific element instead.

Capture type Use it when Trade-off
Viewport The preview has a fixed card or thumbnail size. Content outside the viewport is not included.
Full page The image should show the entire scrollable page. It can produce a very tall image.
Element Only a specific component, such as a chart or product panel, belongs in the preview. The selected element must exist and be visible when capture runs.

Choose dimensions and format based on the destination that consumes the image. There is no universally correct preview size or format established for this unnamed app.

Install Playwright and its browser

For a Node.js project, install the package and the browser binary for the Playwright version you use:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
npm install playwright
npx playwright install chromium

On Linux or in CI, install the browser’s system dependencies as well. Playwright browser binaries are tied to Playwright versions, so repeat browser installation when upgrading Playwright. Pin the package version in your project lockfile and install the corresponding browser during your build or deployment.

Generate a fixed-size preview image

This example captures the first viewport at 1200 by 630 CSS pixels and writes a PNG. Replace the example URL with a page your app is authorized to access. It is an implementation pattern based on Playwright’s documented APIs, not a verified deployment for a particular SaaS stack.

const { chromium } = require('playwright');

async function main() {
  const browser = await chromium.launch();
  try {
    const page = await browser.newPage({
      viewport: { width: 1200, height: 630 },
      deviceScaleFactor: 1,
    });

    await page.goto('https://example.com', { waitUntil: 'networkidle' });
    await page.screenshot({ path: 'preview.png', type: 'png' });
  } finally {
    await browser.close();
  }
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

For a production preview service, choose a readiness condition suited to the page. Some sites keep network requests open, so networkidle may never occur. Waiting for a specific selector or an app-specific ready signal can be more reliable. Set any required authentication, locale, or application state before capture; the appropriate values depend on the app.

Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

Adjust capture scope, resolution and format

Capture the full page

Pass fullPage: true to include the scrollable page rather than just the current viewport:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await page.screenshot({ path: 'full-page.png', fullPage: true });

Capture one element

Locate the target element and take its screenshot. This is useful when a page contains navigation and surrounding content that should not be part of the preview:

const card = page.locator('.preview-card');
await card.screenshot({ path: 'card.png' });

Use a selector that is stable in your app and ensure the element has rendered before capturing it.

Control output scale

deviceScaleFactor: 1 captures at CSS-pixel scale, or one output pixel per CSS pixel. A larger device scale produces more device pixels and can increase image dimensions and file size. Select it based on the consuming surface and storage or transfer budget, rather than assuming higher resolution is always better.

Select image format

Playwright supports PNG, JPEG and WebP screenshots. JPEG and WebP support a quality setting; PNG does not use that option. For example:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await page.screenshot({ path: 'preview.webp', type: 'webp', quality: 80 });
await page.screenshot({ path: 'preview.jpg', type: 'jpeg', quality: 80 });

If the image needs post-processing, obtain screenshot bytes as a buffer instead of writing directly to a file:

const image = await page.screenshot({ type: 'png' });

Run Playwright in Linux, CI or Docker

Browser automation has runtime dependencies in addition to the JavaScript package. In a Linux deployment, install compatible browser binaries and system dependencies for the selected Playwright version. A version-pinned Playwright container image is another option; its image includes browsers and system dependencies, but the Playwright package itself must be installed separately.

For Docker, Playwright recommends using --init. For Chromium, its Docker guidance recommends --ipc=host to reduce out-of-memory crashes. These are container-runtime recommendations, not India-specific requirements. Verify the guidance against the Playwright version and image tag selected for your deployment.

Account for India-specific product needs separately

Playwright does not establish where an Indian SaaS app must be hosted or which regulatory requirements apply. The app’s location, customer data, processing flows and contractual obligations determine those decisions. Select the region and data-handling approach from the product’s requirements; do not infer a hosting or compliance mandate from the fact that the app serves India.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

If the service accepts URLs submitted by users, assess that architecture on its own terms, including what requests the service makes and what data it stores. The exact controls depend on the app and are not specified here.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common capture failures

Symptom Likely cause What to do
Browser launch fails with missing executable The browser binary for the installed Playwright version was not installed. Run npx playwright install chromium for the project version; in Linux, install the required system dependencies too.
Capture works locally but fails in a container The image or host is missing browser system dependencies, or the runtime configuration is unsuitable. Use a compatible Playwright container image or install matching dependencies. Follow the container guidance on --init and Chromium shared memory.
Navigation waits indefinitely The page may have long-lived network activity, making networkidle unsuitable. Wait for a page-specific selector or ready signal, or use a different navigation readiness condition appropriate to the target.
Preview is blank or incomplete The app may not have reached its ready state, or required application state was not set. Set required state before capture and wait for a meaningful page element to appear before taking the screenshot.
Image is unexpectedly large or tall Full-page capture or a higher device scale increases pixel dimensions. Use viewport capture for a compact card and CSS-pixel scale when that resolution is sufficient.

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server for developers. A GET request can return a PNG, JPEG, WebP or PDF; its clean-shot options accept cookie or consent banners and remove more than 60 known consent platforms, newsletter popups and chat widgets before capture, and each step can be turned off. Bot checks, blank pages, timeouts, failed loads and cache hits are not billed, with response headers reporting the page verdict and billing status. Its MCP server provides screenshot and page-info tools for AI agents.

For a URL-based capture, make the request with your API key and target URL. See the ScreenshotNeo API documentation for parameters and response handling.

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 per month on its free plan with no card; paid plans start at $5 for 3,000 screenshots. Sign up for the free plan.

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

Performance, reliability and cost decisions

  • Browser lifecycle: close the browser in a finally block so an error during navigation or capture does not leave the browser process running.
  • Resolution: higher device scale increases output pixel count and can make images larger. Use the lowest resolution that meets the preview’s display needs.
  • Readiness: wait for a condition that indicates the page is ready for your preview. A generic network-idle wait may be unsuitable for pages with ongoing requests.
  • Deployment: keep the browser binary and package versions aligned, and account for browser system dependencies in Linux and container builds.
  • Cost: no current official pricing listing for this app is provided. Estimate Playwright hosting or per-capture costs from the app’s own infrastructure, workload and retention requirements.

Frequently Asked Questions

Can I return the screenshot without saving it to disk?

Yes. Call page.screenshot() without a path; it returns a buffer that your application can pass to storage or image-processing code.

Does this setup guarantee the preview matches what every visitor in India sees?

No. The example controls viewport and browser scale, but the app’s locale, authentication, content state and deployment choices can also affect what a page renders.

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.