Skip to content

Directory Structure

Where laravel-mobile init places your mobile app, which files are yours to edit, and which are generated for you.

Introduction

The laravel-mobile init command never moves your Laravel Rust files. Instead, it adds your mobile app beside them, in the places a Laravel developer would expect to find it:

my-app/
├── Cargo.toml          # your app, plus the [workspace] init adds
├── mobile.toml         # your mobile configuration
├── src/                # your Laravel Rust server, unchanged
├── resources/js/       # your Inertia frontend, unchanged
├── resources/mobile/icon.png
├── apps/mobile/        # the Tauri v2 shell
│   ├── src/lib.rs      # yours: add your own Tauri commands here
│   ├── src/plugins.rs  # generated
│   ├── permissions/    # generated, lets your pages call your commands
│   ├── tauri.conf.json, capabilities/, Info.ios.plist   # generated
│   ├── path-configuration.json, mobile.schema.json      # generated
│   ├── icons/          # generated from resources/mobile/icon.png
│   └── gen/            # Xcode and Gradle projects, generated and gitignored
├── crates/shared/      # Rust your server and app share
├── vendor/             # laravel-rust-mobile and its config crate, until they are on crates.io
└── .agents/skills/building-mobile-apps/SKILL.md

Your Server

Your server stays at the root of your project, exactly where laravel new created it. The init command adds a [workspace] table to your Cargo.toml file with apps/mobile and crates/shared as members, and leaves shared undeclared until a crate uses it. Until Lairport is on crates.io, it also writes the package to vendor/ and adds a [patch.crates-io] entry that points at it. Your comments and formatting are preserved, and cargo run and laravel dev work just as they did before.

Your app talks to your server using ordinary Inertia requests, so there’s no separate mobile API to write.

The apps/mobile Directory

The apps/mobile directory contains the Tauri v2 shell. It loads your Inertia pages in the phone’s own WebView and registers your native plugins.

Most of the files in this directory are generated from your mobile.toml file, so you should change mobile.toml rather than editing them. After you do, run the sync command to regenerate them:

laravel-mobile sync

sync also makes one edit outside the generated folder. Your app’s Vite config, vite.config.ts or its .mts, .js or .mjs variant, gets '**/apps/mobile/**' added to its server.watch.ignored list, and to Vite+’s fmt and lint ignorePatterns, so the formatter and linter leave the generated files alone. This keeps Vite’s watcher out of the native build tree, so it doesn’t watch the files that Tauri and Gradle write there. sync leaves a config alone when it has no ignored list or already mentions apps/mobile.

sync also reads the commands in your app’s tauri::generate_handler![...] calls and writes them to permissions/app-commands.toml, so your server’s pages may call them. Run it after you add a command.

Of course, the dev and build commands sync for you, so you’ll rarely need to run it yourself. In CI, the --check option fails when a generated file is out of date, and it lists the Vite config until that entry is added:

laravel-mobile sync --check

The files that are yours to edit are src/lib.rs, src/main.rs, build.rs, and Cargo.toml. The Xcode and Gradle projects in gen/ are regenerated whenever they’re needed and aren’t committed to source control. When you need custom Swift or Kotlin, you should place it in a Tauri plugin.

The crates/shared Directory

The crates/shared directory holds Rust that both your server and your app compile, such as domain types, validation rules, and encryption helpers. Your server opts in with one line in its Cargo.toml, which the shared Rust documentation explains.

The Agent Skill

The init command also adds a building-mobile-apps skill to .agents/skills and lists it in your AGENTS.md file. This way, coding agents working on your application follow the same conventions you’ll find in this documentation.

When you run init in a terminal, it asks whether to have your coding agent review the app and suggest mobile features. If you say yes, it prints this prompt to paste into your agent: “Review this app for mobile with the building-mobile-apps skill.”

Type to search…

↑↓ navigate↵ selectEsc close