|
| 1 | +--- |
| 2 | +title: Project Structure |
| 3 | +i18nReady: true |
| 4 | +--- |
| 5 | + |
| 6 | +A Tauri project is usually made of 2 parts, a Rust project and a JavaScript project (optional), |
| 7 | +and typically the setup looks something like this: |
| 8 | + |
| 9 | +``` |
| 10 | +. |
| 11 | +├── package.json |
| 12 | +├── index.html |
| 13 | +├── src/ |
| 14 | +│ ├── main.js |
| 15 | +├── src-tauri/ |
| 16 | +│ ├── Cargo.toml |
| 17 | +│ ├── Cargo.lock |
| 18 | +│ ├── build.rs |
| 19 | +│ ├── tauri.conf.json |
| 20 | +│ ├── src/ |
| 21 | +│ │ ├── main.rs |
| 22 | +│ │ └── lib.rs |
| 23 | +│ ├── icons/ |
| 24 | +│ │ ├── icon.png |
| 25 | +│ │ ├── icon.icns |
| 26 | +│ │ └── icon.ico |
| 27 | +│ └── capabilities/ |
| 28 | +│ └── default.json |
| 29 | +``` |
| 30 | + |
| 31 | +In this case, the JavaScript project is at the top level, and the Rust project is inside `src-tauri/`, |
| 32 | +the Rust project is a normal [Cargo project](https://doc.rust-lang.org/cargo/guide/project-layout.html) with some extra files: |
| 33 | + |
| 34 | +- `tauri.conf.json` is the main configuration file for Tauri, it contains everything from the application identifier to dev server url, |
| 35 | + this file is also a marker for the [Tauri CLI](/reference/cli/) to find the Rust project, |
| 36 | + to learn more about it, see [Tauri Config](/develop/configuration-files/#tauri-config) |
| 37 | +- `capabilities/` directory is the default folder Tauri reads [capability files](/security/capabilities/) from (in short, you need to allow commands here to use them in your JavaScript code), |
| 38 | + to learn more about it, see [Security](/security/) |
| 39 | +- `icons/` directory is the default output directory of the [`tauri icon`](/reference/cli/#icon) command, it's usually referenced in `tauri.conf.json > bundle > icon` and used for the app's icons |
| 40 | +- `build.rs` contains `tauri_build::build()` which is used for tauri's build system |
| 41 | +- `src/lib.rs` contains the Rust code and the mobile entry point (the function marked with `#[cfg_attr(mobile, tauri::mobile_entry_point)]`), |
| 42 | + the reason we don't write directly in `main.rs` is because we compile your app to a library in mobile builds and load them through the platform frameworks |
| 43 | +- `src/main.rs` is the main entry point for the desktop, and we run `tauri_app_lib::run()` in `main` to use the same entry point as mobile, |
| 44 | + so to keep it simple, don't modify this file, modify `lib.rs` instead |
| 45 | + |
| 46 | +Tauri works similar to a static web host, and the way it builds is that you would compile your JavaScript project to static files first, |
| 47 | +and then compile the Rust project that will bundle those static files in, |
| 48 | +so the JavaScript project setup is basically the same as if you were to build a static website, |
| 49 | +to learn more, see [Frontend Configuration](/start/frontend/) |
| 50 | + |
| 51 | +If you want to work with Rust code only, simply remove everything else and use the `src-tauri/` folder as your top level project or as a member of your Rust workspace |
| 52 | + |
| 53 | +## Next Steps |
| 54 | + |
| 55 | +- [Add and Configure a Frontend Framework](/start/frontend/) |
| 56 | +- [Tauri Command Line Interface (CLI) Reference](/reference/cli/) |
| 57 | +- [Learn how to develop your Tauri app](/develop/) |
| 58 | +- [Discover additional features to extend Tauri](/plugin/) |
0 commit comments