Skip to content

Quick start with Vercel function ​

Learn how to send your first request by using a Vercel Function.

Render PDF ​

Create a Route Handler in an existing Next.js project.

js
// src/app/api/doppio : Route Handler

import { NextResponse } from 'next/server';

export async function POST() {
  const response = await fetch('https://api.doppio.sh/v1/render/pdf/sync', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR API KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      page: {
        pdf: {
          printBackground: true
        },
        goto: {
          url: "https://www.spacejam.com/1996/",
          options: {
            waitUntil: [
              "networkidle0"
            ]
          }
        }
      }
    }),
  });

  const data = await response.json();

  return NextResponse.json(data);
}

Run your Next.js project locally.

bash
npm run dev

Test your route locally, for example with Postman or Insomnia.

POST http://localhost:3000/api/doppio

Deploy the Next.js project to Vercel.

bash
npx vercel

All rights reserved