question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Next.js 13 example

See original GitHub issue

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Summary šŸ’”

There is a great example of how to use MUI with next.js (https://github.com/mui/material-ui/blob/master/examples/nextjs-with-typescript) in this repository.

Yet, a new version of Next.js was released recently: https://nextjs.org/blog/next-13

This introduces several new concepts and ways to write React apps with server-side components in mind. To migrate from the old Next.js to the new version, one needs to do several things:

  • Start using the app/ directory instead of pages/ (although this can be done incrementally)
  • Inside the components of the app/ directory, one has to use fetch (or any other async/await-based data fetching method instead of getInitialProps, getServerSideProps, or getStaticProps.
  • The _document.tsx and _app.tsx should be refactored into a global layout.tsx: https://beta.nextjs.org/docs/upgrade-guide#migrating-_documentjs-and-_appjs

It would be great to get directions on how to use MUI with emotion styles and cache in this scenario. Would be even better to have a sample app like the one above.

Examples 🌈

No response

Motivation šŸ”¦

Next.js 13 is a major new version that introduces several exciting features that would be really great to use in our apps. It would be great to have a guide or directions on how to integrate MUI with the new version of Next.js instead of the old _document and _app based one.

I think there will be many developers that would want to update to the newer version and might get stuck (like myself) on the MUI integration and how the emotion styles and cache work on this new ā€œserver-firstā€ environment without getInitialProps.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:43
  • Comments:15 (8 by maintainers)

github_iconTop GitHub Comments

7reactions
dohomicommented, Oct 28, 2022

I think the NextJS examples needs to be split into two separate examples: pages and app folder based. For now only pages will work due to the underlying Emotion issue https://github.com/vercel/next.js/issues/41994

4reactions
MartinXPNcommented, Oct 27, 2022

@mnajdova I don’t think this is a duplicate of #34893 Here we ask for a working example app that would work with Next.js 13 (similar to the previous Next.js version https://github.com/mui/material-ui/blob/master/examples/nextjs-with-typescript ), while the other issue reports a bug with hydration.

I think those are completely different requests/issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Blog - Next.js 13
Next.js 13 introduces layouts, React Server Components, and streaming in the app directory, as well as Turbopack, an improved imageĀ ...
Read more >
Next.js 13: Working with the new app directory - LogRocket Blog
Hands-on with Next.js 13. Let's experiment with all the new features in Next.js 13 by running through an example.
Read more >
Next.js 13 App Playground - Vercel
Next.js App Directory Playground ; Layouts: Easily share UI while preserving state and avoiding re-renders. ; Server Components: Making server-first the defaultĀ ...
Read more >
Next.js 13 Layouts by Example - Mechanical Rock Blogs
Next.js 13 Layouts by Example ; page.tsx is used to define the UI of a route. ; layout.tsx is used to define a...
Read more >
Next.js 13 - What are the new features? - Refine Dev
Next.js 13 is built on top of Turbopack, a native, rust-based compiler, and successor to Webpack. Turbopack takes only 1.8 seconds duringĀ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found