Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ opt-level = 1
opt-level = 3

[[workspace.metadata.leptos]]
# project name
name = "{{project-name}}"
bin-package = "server"
lib-package = "frontend"
Expand Down
86 changes: 72 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,95 @@
# Tailwind-Leptos-Tauri Template

Simple template to use ssr leptos with tauri for ios/android/windows/macos/linux and web dev
Simple template to use SSR leptos with Tauri for iOS, Android, Windows, Mac, Linux and Web.

To get started just use cargo generate with this repo.
To get started just use [cargo generate](https://crates.io/crates/cargo-generate) with this repo.

```bash
cargo generate --git https://github.com/Alt-iOS/tailwind-leptos-tauri-template.git
```

To test everything is working, run `cargo tauri dev` and `cargo leptos watch` to see the app in the browser and app.

Thanks to the leptos and tauri teams for the amazing work.
Thanks to the Leptos and Tauri teams for the amazing work.
Also all credit to [sjud](https://github.com/sjud/leptos_tauri_from_scratch/tree/main) and [Krzysztof](https://gitlab.com/cristofa/tauri-leptos-template) for their examples, as they were the base for this template.

This project differs as it:

- Adds tailwind to sjud's example
- Adds Tailwind to sjud's example
- Adds SSR to Krzysztof
- Separates the server from the frontend crate
- Separated the app module from the frontend crate
- Separated the backend logic from the rest

Structure:
## Structure
- `/app/` - UI section
- `/frontend/` - launch point for the hydration/csr
- `/backend/` - server logic and server functions
- `/server/` - the launch point of the axum server
- `/src-tauri/` - Tauri related settings, build script

## Test everything is working

### Prerequisites
#### 1. Tauri CLI
> See if Tauri CLI is installed:
> ```
> cargo tauri --version
> ```
Install Tauri CLI:
```bash
cargo install tauri-cli
```

#### 2. Leptos CLI
> See if Leptos CLI is installed:
> ```
> cargo leptos --version
> ```
Install Leptos CLI:
`cargo-leptos` has a dependency on `openssl-sys` that requires Perl to compile.
1. Download portable Strawberry Perl from https://strawberryperl.com/
1. Extract it
1. Run `portableshell.bat`
1. From that shell go to this project directory
1. Install Leptos CLI using
```bash
cargo install cargo-leptos
```

#### 3. wasm32-unknown-unknown target
> See if the target is installed:
> ```bash
> rustup target list --installed
> ```
Install the target:
```bash
rustup target add wasm32-unknown-unknown
```

- App: UI section
- frontend: launch point for the hydration/csr
- backend: server logic and server functions
- server: the launch point of the axum server
- src-tauri: tauri related settings, build script
### Launch native app
```bash
cargo tauri dev
```

### Serve web app
```bash
cargo leptos watch
```

## How To
### Update wasm-bindgen version
```
cargo update -p wasm-bindgen --precise <version>
```
Recompile frontend:
```
cd frontend
cargo clean
cargo leptos build
```

Mobile dev:
## Mobile dev
`cargo tauri android init && cargo tauri ios init`

- iOS requires a mac and XCode
- Android requires JVM 17 or modifying the gradle version.
You can changge it in the distributionUrl and for compatibility [check](https://docs.gradle.org/current/userguide/compatibility.html)
You can change it in the distributionUrl and for compatibility [check](https://docs.gradle.org/current/userguide/compatibility.html)
21 changes: 21 additions & 0 deletions cargo-generate.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[template]
# This is the correct syntax for older versions that don't support wildcards.
# We list every single problematic file by its full path from the project root.
exclude = [
"src-tauri/icons/128x128.png",
"src-tauri/icons/[email protected]",
"src-tauri/icons/32x32.png",
"src-tauri/icons/Square107x107Logo.png",
"src-tauri/icons/Square142x142Logo.png",
"src-tauri/icons/Square150x150Logo.png",
"src-tauri/icons/Square284x284Logo.png",
"src-tauri/icons/Square30x30Logo.png",
"src-tauri/icons/Square310x310Logo.png",
"src-tauri/icons/Square44x44Logo.png",
"src-tauri/icons/Square71x71Logo.png",
"src-tauri/icons/Square89x89Logo.png",
"src-tauri/icons/StoreLogo.png",
"src-tauri/icons/icon.icns",
"src-tauri/icons/icon.ico",
"src-tauri/icons/icon.png"
]
4 changes: 0 additions & 4 deletions src-tauri/.cargo/config.toml

This file was deleted.

1 change: 1 addition & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ serde_json = "*"
#tauri-plugin-devtools = { git = "https://github.com/crabnebula-dev/devtools", version = "2.0.0-beta.0" }

[features]
mobile = []
#default = ["custom-protocol"]
custom-protocol = ["tauri/custom-protocol"]
2 changes: 1 addition & 1 deletion src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg_attr(mobile, tauri::mobile_entry_point)]
#[cfg_attr(feature = "mobile", tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.run(tauri::generate_context!())
Expand Down
4 changes: 2 additions & 2 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"productName": "{{project-name}}_app",
"productName": "{{project-name}}-app",
"version": "0.1.0",
"identifier": "com.tauri.dev0",
"build": {
Expand All @@ -16,7 +16,7 @@
{
"fullscreen": false,
"resizable": true,
"title": "template",
"title": "{{project-name}}",
"width": 800,
"height": 600
}
Expand Down
11 changes: 0 additions & 11 deletions tailwind.config.js

This file was deleted.

8 changes: 8 additions & 0 deletions tailwind.config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
content:
relative: true
files:
- "./*.html"
- "./app/src/**/*.rs"
theme:
extend: {}
plugins: []