Nuxt API

defineOgImageScreenshot()

Introduction

The defineOgImageScreenshot() composable allows you to take a screenshot of the page and use it as the image.

This requires the chromium renderer, check the Chromium guide for more information.

Screenshots require Chromium which is not available on serverless platforms (Vercel, Netlify, AWS Lambda) due to binary size limits. You must either prerender your images at build time or use Satori / Takumi with a custom component instead.

Props

colorScheme

  • Type: 'dark' | 'light'
  • Default: 'light'

The color scheme to use when generating the image. This is useful for generating dark mode images.

defineOgImageScreenshot({
  colorScheme: 'dark'
})

delay

  • Type: number
  • Default: 0

The delay to wait before taking the screenshot. This is useful if you want to wait for animations to complete.

defineOgImageScreenshot({
  // wait 2 seconds
  delay: 2000
})

mask

  • Type: string
  • Default: undefined

HTML selectors that should be removed from the image. Useful for removing popup banners or other elements that may be in the way.

defineOgImageScreenshot({
  mask: '.popup-banner, .cookie-banner'
})

selector

  • Type: string
  • Default: undefined

The selector to take a screenshot of. This is useful if you want to exclude header / footer elements.

defineOgImageScreenshot({
  selector: '.page-content'
})
Did this page help you?