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

Example using next with <CacheProvider/> in pages/_app.tsx. #65

Closed
ziggy6792 opened this issue Mar 8, 2022 · 2 comments
Closed

Example using next with <CacheProvider/> in pages/_app.tsx. #65

ziggy6792 opened this issue Mar 8, 2022 · 2 comments

Comments

@ziggy6792
Copy link

ziggy6792 commented Mar 8, 2022

Hi

Thanks a lot for this tool and your examples and docs.

I am trying to use tss-react with next

I read your docs here https://docs.tss-react.dev/ssr/next.js and checked-out the example here https://github.com/garronej/tss-react/tree/main/src/test/apps/ssr

When I move the cache provider to _app.tsx the styles no longer work when server side rendering (I get an initial un-styled page from the server which is then styled on the client)

tss-react

Here is a my code.

https://github.com/ziggy6792/tss-react/tree/provider-in-app

Thanks a lot

@ziggy6792 ziggy6792 changed the title Example using next with <CacheProvider/> pages/_app.tsx. Example using next with <CacheProvider/> in pages/_app.tsx. Mar 8, 2022
garronej added a commit that referenced this issue Mar 8, 2022
@garronej
Copy link
Owner

garronej commented Mar 8, 2022

Hi @ziggy6792,
Thank you for coming up with a sample project to show me the issue you are experiencing, if everyone could do like this it would save me a lot of time 👍🏻 .
The problem is that you import createMuiCache in _document.tsx from index.tsx instead of _app.tsx.
See here.

Nevertheless it's a good idea to put the providers in _app.tsx. I updated the example SSR app.

@garronej garronej closed this as completed Mar 8, 2022
gitbook-com bot pushed a commit that referenced this issue Mar 8, 2022
@ziggy6792
Copy link
Author

Hi @garronej

Oops my mistake.
Thanks so much and thanks again for a great tool.
I much prefer using this compared to the new emotion styled api

gitbook-com bot pushed a commit that referenced this issue Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants