tamagui: Starter Next JS production build crashes with "Missing theme."
Current Behavior
When using the app router and opening your app in the browser, the page will fail with Application error: a client-side exception has occurred (see the browser console for more information)..
The console will give the following error: Error: Missing theme.
Expected Behavior
Both routers should work.
Tamagui Version
Latest
Platform (Web, iOS, Android)
Web
Reproduction
- Create a new starter repo
- Run cd apps/next && yarn build && yarn serve
- Press on "Change router: app" -> The app will crash
2nd reproduction case:
- host a fresh tamagui starter on vercel
- Press on "Change router: app" -> The app will crash
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 20 (6 by maintainers)
Production builds crash with “Missing theme” when using the App Router, which makes it essentially impossible to use Tamagui in modern Next.js projects. 😦
Really hoping this can be prioritized — any known workarounds or updates would be greatly appreciated!
We are solving this.
I’m experiencing this on native after upgrading to expo 53
In version 1.126.0 this is fixed! But it doesn’t work when you remove
disableThemesBundleOptimize. I am not sure why. Also I thinkdisableThemesBundleOptimizeis not a nice solution, I requested extra explanations in the Discord for future readers.When using
disableThemesBundleOptimizein the next.config my Vercel deployment builds and has no theme error. When you remove it, the build gives errors still. you see a Vercel Build that has it removed with the reproduction being just a simple fork of the Starter, that builds on Vercel and having thedisableThemesBundleOptimizeremoved.Hey, folks. I fixed that error in the latest PR and added an option:
disableThemesBundleOptimizeintowithTamaguiand updatestarter-freelatest version. https://github.com/tamagui/starter-free/blob/e948b66cc81b71ca727d9d771551598532feecd4/apps/next/next.config.js#L27C5-L27C32