· Announcements

Node.js SDK Now Available

Our official Node.js SDK is now available on npm with full TypeScript support.

Line illustration of the RenderScreenshot mascot unboxing a Node.js module connected to a browser

We're happy to announce the official RenderScreenshot Node.js SDK is now available on npm.

Installation

npm install renderscreenshot

Quick Start

import { RenderScreenshot } from 'renderscreenshot';

const client = new RenderScreenshot({
  apiKey: 'rs_live_...'
});

// Take a screenshot
const screenshot = await client.take({
  url: 'https://example.com',
  preset: 'og_card'
});

console.log(screenshot.url); // CDN URL of the screenshot

Features

Full TypeScript Support

The SDK includes complete TypeScript definitions for all options:

import { TakeOptions, ScreenshotResponse } from 'renderscreenshot';

const options: TakeOptions = {
  url: 'https://example.com',
  viewport: { width: 1920, height: 1080 },
  output: { format: 'webp', quality: 90 }
};

Fluent Builder Pattern

Build complex requests with a chainable API:

const screenshot = await client
  .screenshot('https://example.com')
  .viewport(1920, 1080)
  .fullPage()
  .format('webp')
  .quality(90)
  .blockAds()
  .take();

URL Generation

Generate signed URLs for use in <img> tags:

const client = new RenderScreenshot({
  publicKey: 'rs_pub_...',
  secretKey: 'rs_secret_...'
});

const url = client.generateUrl({
  url: 'https://example.com',
  preset: 'og_card',
  expiresIn: '7d'
});

// Safe to use in HTML
// <img src={url} />

Batch Processing

Process multiple URLs efficiently:

const results = await client.batch({
  urls: [
    'https://example.com/page1',
    'https://example.com/page2',
    'https://example.com/page3'
  ],
  preset: 'og_card'
});

Webhook Verification

Verify webhook signatures securely:

import { verifyWebhookSignature } from 'renderscreenshot';

const isValid = verifyWebhookSignature({
  payload: req.body,
  signature: req.headers['x-webhook-signature'],
  secret: process.env.WEBHOOK_SECRET
});

Examples

Next.js API Route

// pages/api/screenshot.ts
import { RenderScreenshot } from 'renderscreenshot';
import type { NextApiRequest, NextApiResponse } from 'next';

const client = new RenderScreenshot({
  apiKey: process.env.RENDERSCREENSHOT_API_KEY!
});

export default async function handler(
  req: NextApiRequest,
  res: NextApiResponse
) {
  const { url } = req.query;

  const screenshot = await client.take({
    url: url as string,
    preset: 'og_card'
  });

  res.redirect(screenshot.url);
}

Express Middleware

import express from 'express';
import { RenderScreenshot } from 'renderscreenshot';

const app = express();
const client = new RenderScreenshot({ apiKey: '...' });

app.get('/screenshot', async (req, res) => {
  const screenshot = await client.take({
    url: req.query.url,
    viewport: { width: 1200, height: 630 }
  });

  res.json({ url: screenshot.url });
});

Documentation

Full documentation is available at /docs/sdks/nodejs.


Tutorials

Questions or feedback? Reach out at [email protected].