Description
I've started experimenting with using Material UI and Joy UI components with Remix and I've run into a few bugs and blockers along the way. Browsing the issues here, I see several open threads where folks are discussing the same problems I've bumped into, so I thought it might be helpful to create an umbrella issue to bring all those discussions to one centralized, up-to-date location where folks can track the progress.
Here are all of the open issues I could find—some are overlapping, others are probably pretty outdated and possibly no longer relevant but I haven't dug too deeply into each one:
Open
- [examples/remix-with-typescript] React 18 version example is required #34170
- [examples] Bizarre render bug when a Button is used inside a Card on SSR (remix-run) #31957
- [docs] Adding
prepend: true
to emotion cache breaks remix example #30359 -
useTheme
doesn't reflect custom theme values when used with Remix SSR setup #31233 - Theme switching doesn't work with Remix #31140
- Issues with esbuild #31835
- [TextField] defaultProps seems to be ignored when React.hydrate is used in SSR setup with Remix #30922
- [CSP] createCache nonce-value added to Cache not applied to inline-styles #38965
Problems
Here are the biggest things I see after reviewing these issues:
- Emotion doesn't play well with Remix / React 18
renderToPipeableStream()
function doesn't work with Emotion, causing hydration issues- supposedly this workaround can resolve the hydration stuff but I haven't tried it yet myself, and it looks like it came before Remix v2 so I don't know if that changes things
- MUI doesn't support ES modules - Directory import is not supported (internal MUI modules) 2.0.0-pre.3 remix-run/remix#7314 (comment)
- Remix uses esbuild under the hood - Issues with esbuild #31835
- as mentioned in [joy-ui] Integrate Joy UI with Remix v2 #39641, it's not ideal to have to customize
entry.client.tsx
andentry.server.tsx
if it can be avoided/minimized
Potential solutions
- migrate away from Emotion - WIP - [RFC] Zero-runtime CSS-in-JS implementation #38137
- publish packages as ES modules - [ESM] Publish packages in ESM module format #30671
- I've read that you can add
serverModuleFormat: 'cjs',
toremix.config.js
to get around this problem, but it didn't work for me when I tried it—maybe I'm missing something
- I've read that you can add
Examples and docs
There are several things we could do to improve the documentation around Remix + MUI!
- We have a nice example of Remix v2 + Material UI: [examples] Upgrade Remix to v2 #39229
- We could use a similar example for Joy UI: [joy-ui] Integrate Joy UI with Remix v2 #39641
- Base UI + Remix example too: [base-ui][docs] Create more examples for Base UI #36193
- It would also be really nice to have Integration guides for Remix like we do with the Next.js App Router
- but maybe it's better to wait on "official" integration guides until we've resolved the bigger problems?
If there are any other known issues or requests to improve the DX, please share them here!