velo Svelte Themes

Velo

A framework for creating cross platform 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.

Velo

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.

Features

  • 🌐 Web to App Bundle - Package web applications into native mobile applications
  • šŸ”„ Hot Reload - Development with hot reload for quick changes
  • šŸ‘ļø Preview - Preview to simulator, emulator, or real devices
  • šŸ“± Cross-Platform - Build for Android and iOS from the same codebase

Preview

Requirements

  • Go 1.18 or newer
  • Node.js and npm
  • Android SDK (for Android builds)
  • Xcode (for iOS builds, macOS only)
  • ADB (Android Debug Bridge)
  • Android Simulator (Android Studio)
  • Gradle (for Android builds)
  • CocoaPods (for iOS builds)
  • iOS Simulator (Xcode)
  • Xcode Command Line Tools
  • Android Studio
  • Xcode

Project Structure

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

Usage

Development Mode with Hot Reload

# 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]

Production Build

# 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]

Platform Bridge

This framework provides a bridge for communication between web applications and the native platform:

For Android

// Call native functions from JavaScript
if (window.AndroidBridge) {
  const deviceInfo = window.AndroidBridge.getPlatformInfo();
  window.AndroidBridge.showToast("Hello from JavaScript!");
}

For iOS

// 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
}

Web Framework Customization

You can replace React with Vue, Svelte, or Angular by adjusting:

  1. Frontend dependencies in package.json
  2. Build configuration
  3. Build output path in the copyBuildToMobile() function in main.go

License

MIT

Top categories

Loading Svelte Themes