Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rybla/leptos-experiment-1
https://github.com/rybla/leptos-experiment-1
Last synced: about 5 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/rybla/leptos-experiment-1
- Owner: rybla
- License: mit
- Created: 2023-11-23T15:35:11.000Z (12 months ago)
- Default Branch: master
- Last Pushed: 2023-11-23T15:35:13.000Z (12 months ago)
- Last Synced: 2024-03-07T06:44:04.474Z (8 months ago)
- Language: Rust
- Size: 8.79 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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`.