My goal is to create a website with Next.js and to create a mobile app with React Native.
But, I need all the following benefits:
- I need All SSR benefits and features on the web app like server components, etc (essential to me)
- I need to use NEXT.js new routing approach (App router in NEXT v13 and up (not page router))
- I want to have maximum usage of the same code base for both web and mobile app
- I need to use tailwind and shadcn with next and nativewind with react native
- I need CSS and tailwind responsive design features
Now my questions is:
What is the best mixture of libs (tailwind, nativewind, dripsy, shadcn, tamagui, expo, solito, etc), frameworks (next, react-native, react-native-web, etx) to have full SSR benefits and features on the web only and also having native mobile behavior with maximum same code base?
Thank you for taking the time to read and highly appreciate your help
2
Answers
Both Tamagui and React Native Web offer distinct advantages and trade-offs when it comes to SSR compatibility and sharing components between Next.js (web app) and React Native (mobile app). Let's compare them based on these criteria:
1. SSR Compatibility
Tamagui
React Native Web
2. Shared Component for Both Next.js (Web App) and React Native (Mobile App)
Tamagui
React Native Web
Conclusion
1. Tamagui:
Pros: Better SSR support, consistent styling system across platforms, easier to maintain a single codebase for UI components.
Cons: Smaller ecosystem compared to React Native Web.
2. React Native Web:
Pros: Larger ecosystem, direct use of React Native components on the web, extensive library support.
Cons: Limited SSR support, potential hydration issues, may require workarounds for certain components.
Recommendation
If SSR compatibility is a priority and you want a smooth experience with server-side rendering in Next.js, Tamagui is the better choice. It provides a consistent and reliable approach for SSR while allowing you to maintain a shared component library across web and mobile.
If you need to leverage a large ecosystem of React Native components and libraries and can work around the SSR limitations, React Native Web might be suitable, especially if your application can tolerate client-side rendering for certain components.
Ultimately, the choice depends on your project's specific needs and priorities. If SSR and a unified styling system are crucial, go with Tamagui. If you need the flexibility and ecosystem of React Native and can manage the SSR limitations, React Native Web is a viable option.
To achieve your goals, consider the following mixture of libraries and frameworks:
Web App:
Mobile App:
Shared Codebase:
This combination allows you to utilize SSR benefits on the web, native mobile behavior, and share code between both platforms while using Tailwind CSS and Shadcn for styling.