Skip to main content
When developing mobile apps, you need your device or emulator to reach your local backend API. ngrok makes this simple by providing a public HTTPS URL that routes traffic to your local development server.

How it works

  1. Install ngrok
  2. Start your backend API on your development machine
  3. Run ngrok http <port> to get a public HTTPS URL
  4. Point your mobile app at the ngrok URL instead of localhost
  5. Test your app against your local backend from any device

Quick example

Use the HTTPS forwarding URL in your mobile app’s API configuration. Since ngrok provides a valid TLS certificate, your app works without any certificate pinning workarounds.

Start the endpoint from your backend

If your backend is a Next.js or FastAPI app, a framework library opens the endpoint when your backend starts, so you don’t need a separate agent.
The command starts next dev and prints the public URL with a QR code, so you can open it on your phone right away. It also writes the URL into .env.local as NEXT_PUBLIC_APP_URL. See the Next.js library for setup.

Benefits for mobile development

  • Test on real devices: Access your local server from physical phones and tablets on any network.
  • No deployment required: Skip deploying to staging just to test a backend change.
  • HTTPS by default: ngrok provides a valid TLS certificate, so your app’s HTTPS requirements are satisfied automatically.
  • Inspect traffic: Use the Traffic Inspector to see exactly what requests your mobile app is making and what responses it receives.

Stable URLs

Your account’s dev domain doesn’t change when you restart ngrok, so you only need to configure your mobile app once. On paid plans, you can use the --url flag to pick a domain name yourself:

Next steps