This project is a standard Next.js app, so the typical Next.js development process applies (npm run dev for browser-based development). However, there is one caveat: the app must be exported to deploy to iOS and Android, since it must run purely client-side. (more on Next.js export)
To build the app, run:
npm run buildAll the client side files will be sent to the ./out/ directory. These files need to be copied to the native iOS and Android projects, and this is where Capacitor comes in:
npm run syncFinally, use the following run commands to run the app on each platform:
npm run ios
npm run androidTo enable Livereload and Instant Refresh during development (when running npm run dev), find the IP address of your local interface (ex: 192.168.1.2) and port your Next.js server is running on, and then set the server url config value to point to it in capacitor.config.json:
{
"server": {
"url": "http://192.168.1.2:3000"
}
}Note: this configuration wil be easier in Capacitor 3 which recently went into beta.
API Routes can be used but some minimal configuration is required. See this discussion for more information.