Skip to content

@vercel/og does not accept a function as a child (<Foo>{() => 'bar'}</Foo>) #519

Open

Description

@klaasman

Bug report

Description / Observed Behavior

I originally posted this issue on vercel/next.js#52394 but I think satori is the right place for this bug report

The @vercel/og library does not support using a function as children.

❌ For example this won't work:

<Test>{() => <p>Hello from children() as child</p>}</Test>

❌ Assigning children as a prop also doesn't work:

<Test children={() => <p>Hello from children() as prop</p>} />

✅ Any other prop does work:

<Test renderProp={() => <p>Hello from renderProp()</p>} />

The following error is thrown:

error unhandledRejection: Error [TypeError]: Cannot read properties of undefined (reading 'children')
    at n (file:///workspace/node_modules/next/dist/compiled/@vercel/og/index.node.js:15039:29)
    at n (file:///workspace/node_modules/next/dist/compiled/@vercel/og/index.node.js:15039:77)
    at file:///workspace/node_modules/next/dist/compiled/@vercel/og/index.node.js:15039:69
    at Array.map (<anonymous>)
    at n (file:///workspace/node_modules/next/dist/compiled/@vercel/og/index.node.js:15039:58)
    at pu (file:///workspace/node_modules/next/dist/compiled/@vercel/og/index.node.js:15042:10)
    at xl (file:///workspace/node_modules/next/dist/compiled/@vercel/og/index.node.js:17132:21)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async render (file:///workspace/node_modules/next/dist/compiled/@vercel/og/index.node.js:18709:15)
    at async Object.start (file:///workspace/node_modules/next/dist/compiled/@vercel/og/index.node.js:18753:25) {
  digest: undefined
}

Expected Behavior

With @vercel/og I expect to be able to use functions as children.

Reproduction

  1. go to https://codesandbox.io/p/sandbox/serene-mclean-27v4mn?file=%2Fapp%2Froute.tsx%3A18%2C1-23%2C79
  2. see an image being served with the text "Hello from renderProp"
  3. Uncomment one of the broken test cases in the file /app/route.tsx
  4. reload image
  5. it won't load

Additional Context

Satori version, and any other context about the problem here.

Activity

  1. klaasman commented on Aug 11, 2023

    @klaasman
    Author

    Yep I noticed too the playground seems to accept it, but it won't work when it's ran via next.js - see attached codesandbox.

  2. sahithyandev commented on Jul 27, 2026

    @sahithyandev

    @vercel/og package is using satori 0.25.0 where as the online playground is probably using a later version. Satori's latest version is 0.29.0. @vercel/og is shipping in compiled form which means we cannot use overrides configuration in package.json to forcefully use 0.29.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions