An Express.js server that redirects iOS devices to the App Store and all other devices to the Play Store.
- 🍎 Automatic iOS detection → App Store redirect
- 🤖 All other devices → Play Store redirect
- 🔍 Device detection endpoint for testing
- ❤️ Health check endpoint
- Install dependencies:
yarn installBefore running the server, set the required environment variables. You can either:
- Create a
.envfile (copy from.env.example):
cp .env.example .env- Or export them directly:
Option A - Using App ID and Package Name (recommended):
export APP_STORE_APP_ID="your-app-id"
export PLAY_STORE_PACKAGE_NAME="your.package.name"Option B - Using full URLs:
export APP_STORE_URL="https://apps.apple.com/app/idyour-app-id"
export PLAY_STORE_URL="https://play.google.com/store/apps/details?id=your.package.name"Replace:
your-app-idwith your actual App Store app ID (numeric ID)your.package.namewith your Android package name
yarn startyarn devThe server will run on http://localhost:3000 by default (or the port specified in the PORT environment variable).
docker run -p 3000:3000 \
-e APP_STORE_APP_ID="your-app-id" \
-e PLAY_STORE_PACKAGE_NAME="your.package.name" \
ghcr.io/endworks/app-link:latestdocker build -t app-link .docker run -p 3000:3000 \
-e APP_STORE_APP_ID="your-app-id" \
-e PLAY_STORE_PACKAGE_NAME="your.package.name" \
app-linkOr using full URLs:
docker run -p 3000:3000 \
-e APP_STORE_URL="https://apps.apple.com/app/idyour-app-id" \
-e PLAY_STORE_URL="https://play.google.com/store/apps/details?id=your.package.name" \
app-linkdocker run -p 3000:3000 --env-file .env app-linkThe repository includes a GitHub Actions workflow that automatically builds and pushes Docker images to GitHub Container Registry on every push to the main branch. The image is available at ghcr.io/endworks/app-link.
GET /- Main redirect endpoint. Automatically redirects based on device.GET /health- Health check endpoint. Returns server status.GET /detect- Device detection endpoint. Returns detected device type (useful for testing).
curl http://localhost:3000/detectcurl -H "User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X)" http://localhost:3000/detectcurl -H "User-Agent: Mozilla/5.0 (Linux; Android 10; SM-G973F)" http://localhost:3000/detectThe server uses User-Agent detection to identify the device type:
- iOS: Detects iPhone, iPad, or iPod → redirects to App Store
- All other devices: Desktop browsers, Android, or any other device → redirects to Play Store
Required (choose one option for each store):
App Store (iOS):
APP_STORE_APP_ID- App Store app ID (numeric ID). If provided, URL will be constructed automatically.APP_STORE_URL- Full App Store URL. Use this if you need a custom URL format.
Play Store (Android/Other):
PLAY_STORE_PACKAGE_NAME- Android package name (e.g.,com.example.app). If provided, URL will be constructed automatically.PLAY_STORE_URL- Full Play Store URL. Use this if you need a custom URL format.
Optional:
PORT- Server port (default: 3000)
Note: You must provide either the ID/package name OR the full URL for each store. The ID/package name takes precedence if both are provided.
MIT