Overview
Capacitor configuration is managed through thecapacitor.config.json file at the root of your project. This file defines how Capacitor bridges your web application with native platform functionality.
Current Configuration
MediGuide’s Capacitor configuration:capacitor.config.json
This minimal configuration is sufficient for basic Capacitor functionality. Additional options can be added as needed.
Configuration Properties
App Identity
The unique identifier for your application across platforms.
The display name of your application.This name appears:
- On the device home screen
- In app store listings (can be overridden)
- In the app switcher
Web Directory
The directory containing your built web assets.For MediGuide, this points to the output directory of the Vite build process (configured in
package.json):package.json
Advanced Configuration Options
Server Configuration
Configure development server settings for live reload:The URL of your development server. Use your computer’s IP address, not
localhost.Allow HTTP traffic (required for local development on Android 9+).
The URL scheme for Android. Use
"https" for production, "http" for development.Android-Specific Configuration
Add Android-specific settings:Configuration for Android build signing and release type.
Store keystore credentials in environment variables or secure vaults, not in the config file.
The background color to display while the web content is loading.
Enable Chrome DevTools debugging. Set to
true for development, false for production.iOS-Specific Configuration
How to handle safe area insets. Options:
"automatic", "never".Enable or disable scrolling in the web view.
Custom URL scheme for the app.
Plugin Configuration
Configure Capacitor plugins globally:Plugin configurations can also be set at runtime using plugin-specific methods in your application code.
Configuration File Formats
Capacitor supports multiple configuration file formats:MediGuide currently uses
capacitor.config.json. TypeScript configuration (.ts) provides better type safety and IDE support.Best Practices
Security
Never Commit Secrets
Don’t store sensitive information like keystore passwords in the config file.Use environment variables instead:
capacitor.config.ts
Development Workflow
Separate Dev and Prod Configs
Consider using environment-specific configurations:
capacitor.config.jsonfor productioncapacitor.config.dev.jsonfor development
--config flag to specify:Syncing Configuration
After making changes tocapacitor.config.json, sync the configuration to native projects:
- Copies web assets to native projects
- Updates native configuration based on
capacitor.config.json - Installs and updates Capacitor plugins
- Generates native project files if needed
Integration with Build Process
The configuration ties into MediGuide’s build workflow:package.json
Environment Variables
You can use environment variables in TypeScript config files:capacitor.config.ts
Troubleshooting
Configuration Not Applied
If changes aren’t taking effect:Invalid Configuration
Validate your configuration:Build Errors After Config Changes
If you encounter build errors:- Verify
webDirpoints to the correct output directory - Ensure the web assets have been built (
npm run build) - Check that
appIdfollows reverse-domain naming (e.g.,com.company.app) - Sync the configuration:
npx cap sync