Skip to content

feat: support parent parameter in generateMetadata() #375

@james-elicx

Description

@james-elicx

Summary

Next.js's generateMetadata() accepts a second parent parameter of type Promise<ResolvedMetadata>, which resolves to the accumulated metadata from ancestor segments. This allows patterns like:

export async function generateMetadata({ params }, parent) {
  const previousImages = (await parent).openGraph?.images || []
  return { openGraph: { images: ['/new-image.jpg', ...previousImages] } }
}

Next.js uses an eager-execution-with-serial-resolution approach: all generateMetadata() calls are kicked off concurrently, but the parent promise for each segment resolves serially from root to leaf.

Current behavior

vinext's resolveModuleMetadata() does not pass a parent argument. Apps using await parent in generateMetadata() receive undefined and will likely throw or produce incorrect metadata.

Expected behavior

generateMetadata() should receive a parent promise that resolves to the merged metadata from all ancestor segments, matching Next.js behavior.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions