summary refs log tree commit diff stats
path: root/README.md
blob: adb94cec3d2a39347806448ad1cab437379ec6c3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<picture>
    <source srcset="https://raw.githubusercontent.com/leptos-rs/leptos/main/docs/logos/Leptos_logo_Solid_White.svg" media="(prefers-color-scheme: dark)">
    <img src="https://raw.githubusercontent.com/leptos-rs/leptos/main/docs/logos/Leptos_logo_RGB.svg" alt="Leptos Logo">
</picture>

# Leptos Client-Side Rendered (CSR) App Starter Template

This is a template for use with the [Leptos] web framework using the [Trunk]
tool to compile and serve your app in development.

## Creating your repo from the template

This template requires you to have `cargo-generate` and `trunk` installed.
[`leptosfmt`](https://github.com/bram209/leptosfmt) is optional but highly
recommended. You can install them with

```sh
cargo install cargo-generate trunk leptosfmt
```

To set up your project with this template, run

```sh
cargo generate --git https://github.com/leptos-rs/start-trunk
```

to generate your new project, then

```sh
cd {{project-name}}
```

to go to your newly created project.

By default, this template uses Rust `nightly` and requires that you've installed
the `wasm` compilation target for your toolchain.

Sass and Tailwind are also supported by the Trunk build tool, but are optional
additions: [see here for more info on how to set those up with
Trunk][trunk-instructions].

If you don't have Rust nightly, you can install it with

```sh
rustup toolchain install nightly --allow-downgrade
```

You can add the `wasm` compilation target to rust using

```sh
rustup target add wasm32-unknown-unknown
```

## Developing your Leptos CSR project

To develop your Leptos CSR project, running

```sh
trunk serve --port 3000 --open
```

will open your app in your default browser at `http://localhost:3000`.

## Deploying your Leptos CSR project

To build a Leptos CSR app for release, use the command

```sh
trunk build --release
```

This will output the files necessary to run your app into the `dist` folder; you
can then use any static site host to serve these files.

For further information about hosting Leptos CSR apps, please refer to [the
Leptos Book chapter on deployment available here][deploy-csr].

[deploy-csr]: https://book.leptos.dev/deployment/csr.html
[leptos]: https://github.com/leptos-rs/leptos
[trunk]: https://github.com/trunk-rs/trunk
[trunk-instructions]: https://trunkrs.dev/assets/