Skip to content
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

Improve integration with Next.js #26561

Closed
xaiborweb opened this issue Jun 2, 2021 · 11 comments
Closed

Improve integration with Next.js #26561

xaiborweb opened this issue Jun 2, 2021 · 11 comments
Labels
docs Improvements or additions to the documentation examples Relating to /examples nextjs status: expected behavior Does not imply the behavior is intended. Just that we know about it and can't work around it

Comments

@xaiborweb
Copy link

xaiborweb commented Jun 2, 2021

Currently the version of next.js 10.2.3, does not recommend using getInitialProps, in addition to most frameworks to integrate them with next.js it is enough to import in _app.js and wrap <Component {... pageProps} />

But the example of integration of material-ui with next.js is more than 1 year old, it uses getInitialProps and forces us to edit _document.js in addition to adding an effect to _app.js to remove jssStyles.

I suggest if you could please review this and update the integration with next.js thanks.

@xaiborweb xaiborweb added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jun 2, 2021
@eps1lon eps1lon added docs Improvements or additions to the documentation new feature New feature or request and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jun 2, 2021
@oliviertassinari
Copy link
Member

oliviertassinari commented Jun 3, 2021

does not recommend using getInitialProp

@xaiborweb How would you solve the inlining of critical CSS in the <head> problem? Our example reproduces the pattern used in the official styled-components example. I'm not aware of any alternatives.

@re-thc

This comment was marked as resolved.

@ghost

This comment was marked as resolved.

@oliviertassinari
Copy link
Member

oliviertassinari commented Jun 5, 2021

Here is why <style> should be under the <head> and not the <body>:

@re-thc
Copy link

re-thc commented Jun 6, 2021

@oliviertassinari are the emotion docs also incorrect?

This only applies if you’re using vanilla Emotion or a version of Emotion prior to v10. For v10 and above, SSR just works in Next.js.

I assume that's what Chakra UI, the quoted example followed.

@oliviertassinari
Copy link
Member

oliviertassinari commented Jun 6, 2021

are the emotion docs also incorrect?

@re-thc IMHO, yes, Emotion docs is incorrect. I understand the great DX in having SSR work without any configurations but it's great for end-ussers. A configuration step is required and it didn't stop styled-components to be popular.

I'm closing we haven't identified further opportunities to improve the integration with Next.js

@oliviertassinari oliviertassinari changed the title Update integration with next.js Improve integration with next.js Jul 6, 2021
@oliviertassinari oliviertassinari changed the title Improve integration with next.js Improve integration with Next.js Jul 6, 2021
kodiakhq bot pushed a commit to 3x071c/lsg-remix that referenced this issue Apr 23, 2022
🙈 Fix `<style>` elements bleeding into the document `<body>`, a place where they [do not belong](mui/material-ui#26561 (comment))
ℹ️ Removed Remix/React control of the entire document to drastically simplify emotion logic. This also means the Remix `meta`/`link` features no longer work -> [react-helmet](https://github.com/nfl/react-helmet)

Closes #221
@guidorice

This comment was marked as outdated.

@gottfired

This comment was marked as outdated.

@fuomag9

This comment was marked as resolved.

@oliviertassinari

This comment was marked as resolved.

@oliviertassinari oliviertassinari added status: expected behavior Does not imply the behavior is intended. Just that we know about it and can't work around it nextjs examples Relating to /examples and removed new feature New feature or request v5.x labels Feb 27, 2024
@famdude
Copy link

famdude commented Apr 20, 2024

does this issue have any relation to the delay for styles to be applied on next js ssr?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation examples Relating to /examples nextjs status: expected behavior Does not imply the behavior is intended. Just that we know about it and can't work around it
Projects
None yet
Development

No branches or pull requests

8 participants