Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you use Next.js with a React Native App?

I have recently been learning Next.js for React and I like the routing system a lot more than react navigation. Now I am about to start a react native frontend and I was wondering if you can utilise Next.js's routing system in react native as well as it's other benefits. I know that you can use it with expo but I am a little confused as to how it all works and I am starting to wonder if the Next only works on the web side of things..

Does anyone have any experience with this? Any information would be much appreciated.

Thanks!

like image 302
Gus Threlfall Avatar asked Sep 07 '25 00:09

Gus Threlfall


2 Answers

Unfortunately you can't do such thing, due to the fact that the views of react native are Equivalent to native views in Java or Objective C. When you get build version of react native , you are receiving Java or Objective C native views thank to react native's RN bridge. Meanwhile, when you get build version of your Next.js project, you are going to receive HTML, CSS, JS and these codes are not familiar to native platforms.

However, you can use your Next.js backend as your endpoints and fetch data in react native via calling this endpoints.

UPDATE Oct_2022:

there seem to be a new tool created for this purpose , called solito. I haven't used it personally but it might meet your needs.

March 2025: Solito now has 3.7k stars on Github, and Fernando Rojo was hired by Vercel as "Head of Mobile".

UPDATE Jan_2023:

It looks like there are more Tools being created for Both web and native platforms , check react-native-web

like image 149
Moein moeinnia Avatar answered Sep 09 '25 21:09

Moein moeinnia


You can check out Tauri. With that you can create from Next.js, React, Svelte etc. cross-platform native Apps. Currently, Windows, Mac and Linux are supported stable. Android & iOS is currently in Alpha

The magic behind Tauri is, that they provide around your Frontend library/framework a Rust layer with that you can interact with platform native APIs. They call it Commands.

You can find the guide for Next.js here.

Also, if it's not exactly answering the question - "Is it possible to use Next.js in React native?" - I hope that it's helping everyone who is searching for a solution to use Next.js as Cross-Platform Frontend Framework

like image 38
Micha M. Avatar answered Sep 09 '25 23:09

Micha M.