puck icon indicating copy to clipboard operation
puck copied to clipboard

Allow access to metadata outside of render and resolveData

Open 1benw opened this issue 2 months ago • 3 comments

Description

Currently data passed to puck in the metadata object is only available within render and resolveData functions. It would be useful if this was available in the puck context through usePuck() so it can be used elsewhere like in the header override for example.

Considerations

The same data could be passed through custom context but since metadata already exists, surely it would make sense that this data can be accessed in the puck context as well.

Proposals

Proposal 1

Make metadata available within the usePuck hook

1benw avatar Oct 14 '25 13:10 1benw

Somewhat related to https://github.com/puckeditor/puck/issues/1365

1benw avatar Oct 14 '25 13:10 1benw

Hey @1benw!

Interesting! I do wonder if it might be better to provide a separate prop for this, since metadata, at least to me, feels tied to the Puck data and is also passed to the Render component. That could make people think they can use usePuck within it.

Just to make sure I understand the need: you're basically looking for a way to quickly provide your own context values to the Editor, right?

FedericoBonel avatar Oct 15 '25 03:10 FedericoBonel

Yes the use case was the data to be available and used in the editor, specifically in overrides like the header so having the data in the override props could also be an option.

1benw avatar Oct 15 '25 08:10 1benw