TWA Setup
Configure your TWA project using the interactive setup script.
Prerequisites
- Node.js 20+
- Java JDK 17+ (for keytool and gradle)
- Your PWA deployed with HTTPS
Quick Setup
The template includes an interactive setup script that handles everything:
bash
cd twa
./scripts/init-twa.shThis script will:
- Prompt for your app configuration
- Generate a signing keystore
- Extract SHA256 fingerprint
- Create
twa-manifest.jsonfrom your input - Update
assetlinks.jsonautomatically - Build the signed APK
Interactive Prompts
The script will ask for:
| Prompt | Description | Example |
|---|---|---|
| App Name | Full application name | My Solana App |
| Package ID | Unique Android identifier | com.mycompany.myapp |
| Host URL | Your deployed PWA domain | myapp.vercel.app |
| Keystore Password | Password for signing key | (secure password) |
Example Session
=== Solana Mobile TWA Setup ===
Enter your app name: My Solana App
Enter your package ID (e.g., com.company.app): com.mycompany.myapp
Enter your host URL (without https://): myapp.vercel.app
Enter keystore password: ********
Creating keystore...
Extracting SHA256 fingerprint...
Generating twa-manifest.json...
Updating assetlinks.json...
Building APK...
✓ Setup complete!
APK: app-release-signed.apk
Fingerprint: AA:BB:CC:DD:...Configuration Files
twa-manifest.json
Generated by the init script with your configuration:
json
{
"packageId": "com.mycompany.myapp",
"host": "myapp.vercel.app",
"name": "My Solana App",
"launcherName": "My Solana App",
"display": "standalone",
"themeColor": "#9945FF",
"navigationColor": "#000000",
"backgroundColor": "#0a0a0a",
"startUrl": "/",
"iconUrl": "/icons/icon-512x512.png",
"splashScreenFadeOutDuration": 300,
"enableNotifications": true,
"fallbackType": "customtabs",
"orientation": "portrait",
"signing": {
"keystore": "./android.keystore",
"alias": "android"
},
"appVersionCode": 1,
"appVersionName": "1.0.0",
"minSdkVersion": 24,
"targetSdkVersion": 34
}Key Fields
| Field | Description |
|---|---|
packageId | Unique Android app identifier |
host | Your deployed domain (no https://) |
themeColor | Status bar color |
navigationColor | Navigation bar color |
backgroundColor | Splash screen background |
fallbackType | customtabs shows URL bar if verification fails |
minSdkVersion | Minimum Android version (24 = Android 7.0) |
twa-manifest.template.json
The template file with placeholder values. The init script uses this as a base.
Manual Configuration
If you prefer manual setup:
1. Install Bubblewrap
bash
npm install -g @bubblewrap/cli2. Create Keystore
bash
keytool -genkeypair \
-alias android \
-keyalg RSA \
-keysize 2048 \
-validity 10000 \
-keystore android.keystore3. Get SHA256 Fingerprint
bash
keytool -list -v -keystore android.keystore | grep SHA2564. Create twa-manifest.json
Copy twa-manifest.template.json to twa-manifest.json and update:
packageId- Your unique package IDhost- Your deployed domainnameandlauncherName- Your app name
5. Update assetlinks.json
Edit public/.well-known/assetlinks.json:
- Replace
YOUR_PACKAGE_ID_HEREwith your package ID - Replace
YOUR_SHA256_FINGERPRINT_HEREwith your fingerprint
6. Build
bash
./scripts/build-twa.shKeystore Security
Important
Your android.keystore file is critical:
- Never commit to git (it's in
.gitignore) - Back it up securely - You need it for all future updates
- Remember your password - Cannot be recovered if lost
Lost keystore = new app listing on dApp Store.
Directory Structure
After setup:
twa/
├── twa-manifest.json # Your configuration (gitignored)
├── twa-manifest.template.json # Template with placeholders
├── android.keystore # Signing key (gitignored)
├── CustomLauncherActivity.java
├── scripts/
│ ├── init-twa.sh # Interactive setup
│ ├── build-twa.sh # Rebuild script
│ └── update-assetlinks.sh # Update fingerprint
└── (generated after build)
├── app/ # Android project
└── app-release-signed.apkDeploy Your PWA
After running init, deploy your PWA with the updated assetlinks.json:
bash
# From project root
npm run build
# Deploy to Vercel/your hostingVerify it's accessible:
bash
curl https://your-domain.com/.well-known/assetlinks.json