Updated 20 February 2025
In this blog we will discuss about How to Build a Mobile App with Hotwire.
Hotwire is a web framework that reduces the need for JavaScript by sending updated HTML from the server to the browser.
It uses tools like Turbo for navigation and updates, and Stimulus for small JavaScript features.
Turbo Native integrates web views with native navigation, enabling mobile apps to reuse web pages while maintaining a native look and feel.
Hotwire is a framework that helps build modern web and mobile apps without writing a lot of JavaScript.
Instead of making the browser do most of the work, it shifts more work to the server.
When something changes, the server sends ready-to-use HTML to the browser or app, instead of raw data like JSON that needs extra processing with JavaScript.
Hotwire consists of three main below mention tools:
Handles page navigation and real-time updates.
a) Instead of fully reloading the page, Turbo can replace just the parts of the page that need updating, making it fast and smooth.
b) For example, when you click a link or submit a form, Turbo updates the page instantly without reloading.
Stimulus is a small JavaScript library that adds interactive features to your app, like expanding menus, showing popups, or handling button clicks.
It helps you keep your JavaScript simple and organized by connecting small behaviors to your HTML.
In Hotwire Strada is a tools that connects web apps with native apps.
It lets web pages talk to native app features, like accessing the camera or sending notifications, so you can combine the best of web and native functionality.
Below is the some reason why we use Hotwire to develop iOS and Android apps.
Hotwire allows you to integrate web content (like HTML) with native app features, making it easier to combine the performance and feel of a native app with the flexibility of web content.
Hotwire sends ready-to-use HTML from the server to the app, so the app can get real-time updates without extra work on the client side. This keeps the app fast and up-to-date.
Hotwire makes app development easier by reducing the need for complex JavaScript. This means you don’t have to worry about managing complicated code or APIs for the user interface.
With Hotwire, the app loads content faster because the server does most of the work, which lightens the load on the device and improves the user experience.
Hotwire allows you to reuse existing web pages in a mobile app, reducing the need to duplicate effort by rebuilding web-based content from scratch for mobile platforms.
On mobile platforms, Hotwire works with Turbo Native, which integrates web views for content with native navigation.
This hybrid approach allows developers to:
Reuse existing web pages in mobile apps without rebuilding them from scratch.
Provide a native-like user experience with smooth navigation and performance.
Please follow below mention steps to create app using Hotwire in iOS.
Add Hotwire dependency to your iOS project:
First, you need to add the Hotwire package dependency to your iOS project. Follow these steps:
https://github.com/hotwired/hotwire-native-ios
This will integrate the Hotwire Native package into your iOS project.
Open the SceneDelegate.swift file in your Xcode project and you need to add below mention code in SceneDelegate.swift file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
import HotwireNative import UIKit let rootURL = URL(string: "https://wpdev.vachak.com/themes/mobikul/")! class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? private let navigator = Navigator() func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { window?.rootViewController = navigator.rootViewController navigator.route(rootURL) } } |
This file is part of your app’s default structure and handles the app’s UI lifecycle for the window (or scene) that is active at any time.
Once you have replaced the content of the
SceneDelegate file, you can build and run your app.
If everything is set up correctly, the app will launch, and the content from the
rootURL will be displayed in the app, navigating smoothly between pages and sections using Hotwire Native.
For more knowledge about hotwire with iOS you can check here.
Hotwire can also be implemented in other web frameworks, such as:
Django: Using Django-Turbo-Response to send Turbo Streams.
Node.js: Using Express and server-side rendering to send HTML updates.
Laravel: Using Laravel Turbo to enable Turbo Streams and Turbo Drive.
By handling updates at the server level, Hotwire ensures that client-side JavaScript remains minimal, keeping the application lightweight and responsive.
Hotwire for iOS uses the Turbo iOS framework to enable fast, web-native navigation inside an app. It seamlessly integrates web views with native components, improving performance and user experience.
Please follow below mention steps to create app using Hotwire in Android.
1 2 3 4 |
dependencies { implementation("dev.hotwire:core:<updated-version>") implementation("dev.hotwire:navigation-fragments:<updated-version>") } |
dev.hotwire:core
→ Provides core Turbo functionalities for efficient web content loading.dev.hotwire:navigation-fragments
→ Supports Turbo Navigation with Jetpack Navigation and Fragments.After that below mention XML code defines the layout for the main activity in an Android app that uses Hotwire Turbo Native for navigation.
1 2 3 4 5 6 7 8 9 |
<?xml version="1.0" encoding="utf-8"?> <androidx.fragment.app.FragmentContainerView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/main_nav_host" android:name="dev.hotwire.navigation.navigator.NavigatorHost" android:layout_width="match_parent" android:layout_height="match_parent" app:defaultNavHost="false" /> |
FragmentContainerView
android:id="@+id/main_nav_host"
android:name="dev.hotwire.navigation.navigator.NavigatorHost"
android:layout_width="match_parent"
& android:layout_height="match_parent"
app:defaultNavHost="false"
Open the MainActivity.kt file in your project and you need to add below mention code in MainActivity.kt file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import android.os.Bundle import dev.hotwire.navigation.activities.HotwireActivity import dev.hotwire.navigation.navigator.NavigatorConfiguration class HomeActivity : HotwireActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_home) } override fun navigatorConfigurations() = listOf( NavigatorConfiguration( name = "HomeNavigator", startLocation = "https://wpdev.vachak.com/themes/mobikul/", navigatorHostId = R.id.home_nav_host ) ) } |
Inherits from HotwireActivity to enable Turbo navigation features.
Initializes the activity and sets the layout activity_home.xml.
Hotwire Turbo Native defines the navigation setup for the app. It returns a list of NavigatorConfiguration objects, specifying:
Once you have added all above Android code, you can build and run your app.
If everything is set up correctly, the app will launch, and the content form the startLocation will be displayed in the app, navigating smoothly between pages and sections using Hotwire Native.
For more knowledge about hotwire with Android you can check here
Hotwire for Android uses the Turbo Android framework to enable fast, web-native navigation inside an app. It integrates WebViews with native components for a smoother user experience.
For Hotwire to work efficiently, the server must be able to respond with HTML fragments instead of JSON. Here’s how Hotwire is implemented on the backend:
If you’re using Ruby on Rails, you can enable Hotwire with Turbo Streams:
1 2 3 4 5 6 7 8 9 |
class MessagesController < ApplicationController def create @message = Message.create!(message_params) respond_to do |format| format.turbo_stream { render turbo_stream: turbo_stream.append('messages', @message) } format.html { redirect_to messages_path } end end end |
Hotwire enables efficient hybrid app development by combining Turbo Native for iOS and Android, allowing smooth, native-like navigation with reusable web content.
Its use of server-rendered HTML, real-time updates, and minimal JavaScript reduces complexity and enhances performance for responsive, high-performance apps.
Thanks for reading this article.
You can also check other blogs from here for more knowledge.
For more knowledge about hotwire you can check here.
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.