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

Image

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 20 (6 by maintainers)

Most upvoted comments

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!

I’m experiencing this on native after upgrading to expo 53

We are solving this.

I’m experiencing this on native after upgrading to expo 53

Also, while I appreciate your thought of adding disableThemesBundleOptimize, I’m not sure it’s the ideal long-term fix. Since appDir: true is already set, wouldn’t that be enough to infer this is a Next.js App Router setup and apply a fix automatically? Or at least something that is not “disabling optimizations”, we want the optimizations!

Yah, This is only a temporary solution. I will find the deep of the error

In version 1.126.0 this is fixed! But it doesn’t work when you remove disableThemesBundleOptimize. I am not sure why. Also I think disableThemesBundleOptimize is not a nice solution, I requested extra explanations in the Discord for future readers.

When usingdisableThemesBundleOptimize in 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 the disableThemesBundleOptimize removed.

Hey, folks. I fixed that error in the latest PR and added an option: disableThemesBundleOptimize into withTamagui and update starter-free latest version. https://github.com/tamagui/starter-free/blob/e948b66cc81b71ca727d9d771551598532feecd4/apps/next/next.config.js#L27C5-L27C32