Replies: 1 comment
-
I don't think either proposed solution would turn out well. Don't have an alternative from the top of my mind, but you're the first to ask for such feature so it's fine to keep it open and see if others +1 it, if not it probably won't make much sense to implement something for this. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Feature request
Is your feature request related to a problem? Please describe.
Occasionally developers need to render part of their app into a src-less iframe for various reasons (as a sandbox, or isolated styling environment), often using a component like react-frame-component.
However, next/head refers to the global document (and thus,
head
element of parent frame) when updating head elements. This means it cannot, for example, add a custom font inside a src-less iframe. Here's a minimum re-producible codesandbox that illustrates the problem: https://codesandbox.io/s/nexthead-iframe-example-yymx0Describe alternatives you've considered
I've considered forking all the next/head-related code into my project and creating my own HeadContextProvider that provides a HeadManager which is bound to the currently active
document
. Unfortunately this is a lot of code to fork and it would be great if there was a workaround within the next public API.Describe the solution you'd like
I can think of two possible APIs
<Head>
to be passed adocument={document}
prop, which it passes along to HeadManager.updateHead.<HeadContextProvider>
with the new HeadManager instance. This is likely less preferable to option 1 since it requires exposing more next innards.One challenge is that HeadManager is looking for
next-head-count
which won't exist in the document since the iframe document was not rendered by next.Additional context
This is admittedly a very obscure request, so feel free to close it or recommend alternatives if you don't feel its worth addressing within next directly. Just wanted to open up an issue to get your thoughts and document the issue for any future users running into it.
Beta Was this translation helpful? Give feedback.
All reactions