How to send piped response in Next.js API using wkhtmltoimage?

I’m new to Next.js, and I’m trying to use wkhtmltoimage but I can’t seem to send the generated image stream as a response in my Next.js API.

const fs = require('fs')
const wkhtmltoimage = require('wkhtmltoimage').setCommand(__dirname + '/bin/wkhtmltoimage');


export default async function handler(req, res) {
  try {
    await wkhtmltoimage.generate('<h1>Hello world</h1>').pipe(res);
    
    res.status(200).send(res)
  } catch (err) {
    res.status(500).send({ error: 'failed to fetch data' })
  }
}

I know I’m doing plenty of stuff wrong here, can anyone point me to the right direction?