-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global Component Wrapper #140
Comments
Consulting has added an |
I think we would need first class support for this in pages. Otherwise you will have to import the |
Are there any updates on this? I think a template like this would be quite helpful for implementing i18n support, as well as for adding a Custom Field usage highlighter, and other things that require interacting with the entire page from the top-most level component. Our current implementations involve pasting the same component into each template file |
We actually have support for a single global _client.tsx and _server.tsx (in src/templates) that gives you full React rendering control. There's no documentation on it yet, but here's an example. Just note that it's global for every template.
Another option is to create your own layout wrapper than you call in each template, but sounds like you're looking to avoid this.
|
Description
From time to time you want to add a global component wrapper across ALL templates. This could be something UI related or could be something like an analytics provider or a bug reporting provider.
Today the only way to do that is to manually add it to each individual template and wrap each template in shared code. You can abstract this into a
<Layout>
component but that is still tedious and error prone.Next.js has
app.js
and adocument.js
for exactly this reason. Something similar would be helpful.Suggested solution
Do something similar to
next.js
with theirapp.js
anddocument.js
. Remix has anentry.client.js
which is kinda similar as well. https://remix.run/docs/en/v1/api/conventions#entryclienttsx.I'd propose an
app.js
file that lives in thesrc
repo. It allows you add global components that wrap around every template. Under the hood it would do the exact same thing as individually wrapping each page. So something like where<Wrapper>
is a custom componentAlternative
No response
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: