Skip to content

Instantly share code, notes, and snippets.

View DavydeVries's full-sized avatar
⌨️
Smashing on a keyboard and let things work.

Davy de Vries DavydeVries

⌨️
Smashing on a keyboard and let things work.
View GitHub Profile
@DavydeVries
DavydeVries / route.ts
Last active February 16, 2025 11:15
Serverless screenshot API with Puppeteer and Chromium
// /src/app/api/screenshot/route.ts
import puppeteer from 'puppeteer-core'
import chromium from '@sparticuz/chromium-min'
import { NextRequest } from 'next/server'
export const isPreviewOrProduction =
process.env.VERCEL_ENV === 'preview' ||
process.env.VERCEL_ENV === 'production'
async function getBrowser() {