A framework for creating mobile applications using Golang with UI from React, Vue, Svelte, or Angular. This framework uses a WebView approach to wrap web applications into native Android and iOS applications.
golang-browser-mobile/
āāā frontend/ # Web project (React, Vue, etc.)
ā āāā src/ # Frontend web source code
ā āāā App.js # React Native application for Expo
ā āāā app.json # Expo configuration
ā āāā index.html # Main HTML template for web
ā āāā package.json # npm configuration
āāā mobile-shell/ # Mobile wrapper
ā āāā android/ # Android shell
ā āāā ios/ # iOS shell
ā āāā assets/ # Bundled assets
āāā main.go # Main Golang program
āāā README.md # Documentation
# Run in WebView development mode
go run main.go -dev
# Run in development mode with preview to Android emulator/device
go run main.go -dev -preview -android [-device=DEVICE_ID]
# Run in development mode with preview to iOS simulator/device
go run main.go -dev -preview -ios [-device=DEVICE_ID]
# Build Frontend + Android (WebView)
go run main.go -android
# Build Frontend + iOS (WebView)
go run main.go -ios
# Build and run directly on device
go run main.go -android -preview [-device=DEVICE_ID]
This framework provides a bridge for communication between web applications and the native platform:
// Call native functions from JavaScript
if (window.AndroidBridge) {
const deviceInfo = window.AndroidBridge.getPlatformInfo();
window.AndroidBridge.showToast("Hello from JavaScript!");
}
// Call native functions from JavaScript
if (
window.webkit &&
window.webkit.messageHandlers &&
window.webkit.messageHandlers.iOSBridge
) {
window.webkit.messageHandlers.iOSBridge.postMessage({
action: "getPlatformInfo",
});
// iOS will call the setPlatformInfo function that you define in JavaScript
}
You can replace React with Vue, Svelte, or Angular by adjusting:
package.json
copyBuildToMobile()
function in main.go
MIT