Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/srid/leptos-fullstack
A Nix template for full-stack web apps in Rust using Leptos
https://github.com/srid/leptos-fullstack
Last synced: 3 days ago
JSON representation
A Nix template for full-stack web apps in Rust using Leptos
- Host: GitHub
- URL: https://github.com/srid/leptos-fullstack
- Owner: srid
- License: mit
- Created: 2023-07-25T19:17:29.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-09-25T23:14:36.000Z (4 months ago)
- Last Synced: 2025-01-02T00:07:08.726Z (10 days ago)
- Language: Rust
- Homepage:
- Size: 123 KB
- Stars: 74
- Watchers: 2
- Forks: 8
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-leptos - leptos-fullstack - A (Starter Templates / Unofficial)
README
# leptos-fullstack
A Nix template for [full-stack web apps](https://srid.ca/nojs) in Rust using Leptos. Tech used:
- [Leptos](https://leptos.dev/) full-stack framework
- [server functions](https://docs.rs/leptos/latest/leptos/attr.server.html)
- [ssr + hydration](https://leptos-rs.github.io/leptos/ssr/index.html)
- [Axum](https://github.com/tokio-rs/axum) as backend framework
- [Tailwind CSS](https://tailwindcss.com/) for styling
- Build system
- [cargo-leptos](https://github.com/leptos-rs/cargo-leptos)
- [Nix Flakes](https://zero-to-flakes.com/) + [crane](https://github.com/ipetkov/crane)
- Autoformatting using `rustfmt` and `leptosfmt`## Running locally
Enter the Nix shell, and run:
```
# To spin up the dev server
just watch# To run tests
just test
```## Building
```
nix build# To build the rust doccs
nix build .#leptos-fullstack-docs
```You can also `nix run` the app directly.
## Using as flake-parts module
Import `./nix/flake-module.nix` from this repos as a flake-parts module. For an example project, see [nix-browser](https://github.com/juspay/nix-browser).
In the future, we might create a standalone flake-parts module for Leptos.
## Notes
### Single-crate model
This repo uses the single-crate model primarily because the backend-common-frontend split (prior to PR #5; similar to [start-axum-workspace](https://github.com/leptos-rs/start-axum-workspace) template) is not suitable when using [server functions](https://docs.rs/leptos/latest/leptos/attr.server.html) in leptos. Consequently, expect a bunch of `cfg` attributes or macros that make backend-only code conditional upon the `ssr` flag (which is set when compiling the crate for the backend, as opposed to the wasm frontend, which uses `csr`)
## Credits
The Rust code is largely based on [start-axum](https://github.com/leptos-rs/start-axum). Also, credit goes [to @benwis](https://github.com/benwis/benwis_leptos/blob/928ea7e7c20a86be91ad27e75cf297a2fbef681d/flake.nix#L148-L153) for pointers to how `crane` can be made to work with `cargo-leptos`.