diff --git a/examples/counter_isomorphic/README.md b/examples/counter_isomorphic/README.md index 49281cb10..871650cb3 100644 --- a/examples/counter_isomorphic/README.md +++ b/examples/counter_isomorphic/README.md @@ -2,20 +2,39 @@ This example demonstrates how to use a function isomorphically, to run a server side function from the browser and receive a result. -## Server Side Rendering With Hydration +## Client Side Rendering +To run it as a Client Side App, you can issue `trunk serve --open` in the root. This will build the entire +app into one CSR bundle. Make sure you have trunk installed with `cargo install trunk`. -To run it as a server side app with hydration, first you should run +## Server Side Rendering with cargo-leptos +cargo-leptos is now the easiest and most featureful way to build server side rendered apps with hydration. It provides automatic recompilation of client and server code, wasm optimisation, CSS minification, and more! Check out more about it [here](https://github.com/akesson/cargo-leptos) +1. Install cargo-leptos +```bash +cargo install --locked cargo-leptos +``` +2. Build the site in watch mode, recompiling on file changes +```bash +cargo leptos watch +``` +3. When ready to deploy, run +```bash +cargo leptos build --release +``` + +## Server Side Rendering without cargo-leptos +To run it as a server side app with hydration, you'll need to have wasm-pack installed. +0. Edit the `[package.metadata.leptos]` section and set `site-root` to `"pkg"`. This tells leptos that the WASM/JS files generated by wasm-pack +are available at `./pkg`. Building to alternative folders is not supported at this time +1. Install wasm-pack +```bash +cargo install wasm-pack +``` +2. Build the Webassembly used to hydrate the HTML from the server ```bash wasm-pack build --target=web --debug --no-default-features --features=hydrate ``` - -to generate the Webassembly to provide hydration features for the server. -Then run the server with `cargo run` to serve the server side rendered HTML and the WASM bundle for hydration. - +3. Run the server to serve the Webassembly, JS, and HTML ```bash cargo run --no-default-features --features=ssr ``` - -> Note that if your hydration code changes, you will have to rerun the wasm-pack command above -> This should be temporary, and vastly improve once cargo-leptos becomes ready for prime time! diff --git a/examples/hackernews/README.md b/examples/hackernews/README.md index f687ba49f..54d5d0615 100644 --- a/examples/hackernews/README.md +++ b/examples/hackernews/README.md @@ -4,17 +4,37 @@ This example creates a basic clone of the Hacker News site. It showcases Leptos' ## Client Side Rendering To run it as a Client Side App, you can issue `trunk serve --open` in the root. This will build the entire -app into one CRS bundle +app into one CSR bundle. Make sure you have trunk installed with `cargo install trunk`. -## Server Side Rendering With Hydration -To run it as a server side app with hydration, first you should run +## Server Side Rendering with cargo-leptos +cargo-leptos is now the easiest and most featureful way to build server side rendered apps with hydration. It provides automatic recompilation of client and server code, wasm optimisation, CSS minification, and more! Check out more about it [here](https://github.com/akesson/cargo-leptos) + +1. Install cargo-leptos ```bash -wasm-pack build --target=web --no-default-features --features=hydrate +cargo install --locked cargo-leptos +``` +2. Build the site in watch mode, recompiling on file changes +```bash +cargo leptos watch ``` -to generate the Webassembly to provide hydration features for the server. -Then run the server with `cargo run` to serve the server side rendered HTML and the WASM bundle for hydration. +3. When ready to deploy, run +```bash +cargo leptos build --release +``` + +## Server Side Rendering without cargo-leptos +To run it as a server side app with hydration, you'll need to have wasm-pack installed. +0. Edit the `[package.metadata.leptos]` section and set `site-root` to `"pkg"`. This tells leptos that the WASM/JS files generated by wasm-pack +are available at `./pkg`. Building to alternative folders is not supported at this time +1. Install wasm-pack +```bash +cargo install wasm-pack +``` +2. Build the Webassembly used to hydrate the HTML from the server +```bash +wasm-pack build --target=web --debug --no-default-features --features=hydrate +``` +3. Run the server to serve the Webassembly, JS, and HTML ```bash cargo run --no-default-features --features=ssr ``` -> Note that if your hydration code changes, you will have to rerun the wasm-pack command above -> This should be temporary, and vastly improve once cargo-leptos becomes ready for prime time! diff --git a/examples/hackernews_axum/README.md b/examples/hackernews_axum/README.md index cf3a27f05..83c52a56c 100644 --- a/examples/hackernews_axum/README.md +++ b/examples/hackernews_axum/README.md @@ -4,17 +4,37 @@ This example creates a basic clone of the Hacker News site. It showcases Leptos' ## Client Side Rendering To run it as a Client Side App, you can issue `trunk serve --open` in the root. This will build the entire -app into one CRS bundle +app into one CSR bundle. Make sure you have trunk installed with `cargo install trunk`. -## Server Side Rendering With Hydration -To run it as a server side app with hydration, first you should run +## Server Side Rendering with cargo-leptos +cargo-leptos is now the easiest and most featureful way to build server side rendered apps with hydration. It provides automatic recompilation of client and server code, wasm optimisation, CSS minification, and more! Check out more about it [here](https://github.com/akesson/cargo-leptos) + +1. Install cargo-leptos +```bash +cargo install --locked cargo-leptos +``` +2. Build the site in watch mode, recompiling on file changes +```bash +cargo leptos watch +``` +3. When ready to deploy, run +```bash +cargo leptos build --release +``` + +## Server Side Rendering without cargo-leptos +To run it as a server side app with hydration, you'll need to have wasm-pack installed. +0. Edit the `[package.metadata.leptos]` section and set `site-root` to `"pkg"`. This tells leptos that the WASM/JS files generated by wasm-pack +are available at `./pkg`. Building to alternative folders is not supported at this time +1. Install wasm-pack +```bash +cargo install wasm-pack +``` +2. Build the Webassembly used to hydrate the HTML from the server ```bash wasm-pack build --target=web --debug --no-default-features --features=hydrate ``` -to generate the Webassembly to provide hydration features for the server. -Then run the server with `cargo run` to serve the server side rendered HTML and the WASM bundle for hydration. +3. Run the server to serve the Webassembly, JS, and HTML ```bash cargo run --no-default-features --features=ssr ``` -> Note that if your hydration code changes, you will have to rerun the wasm-pack command above -> This should be temporary, and vastly improve once cargo-leptos becomes ready for prime time! diff --git a/examples/todo_app_sqlite/README.md b/examples/todo_app_sqlite/README.md index 5bf5dd2aa..48c0aa2f8 100644 --- a/examples/todo_app_sqlite/README.md +++ b/examples/todo_app_sqlite/README.md @@ -1,21 +1,41 @@ -# Leptos Counter Isomorphic Example +# Leptos Todo App Sqlite -This example demonstrates how to use a server functions and multi-actions to build a simple todo app. +This example creates a basic todo app with an Axum backend that uses Leptos' server functions to call sqlx from the client and seamlessly run it on the server. -## Server Side Rendering With Hydration +## Client Side Rendering +To run it as a Client Side App, you can issue `trunk serve --open` in the root. This will build the entire +app into one CSR bundle. Make sure you have trunk installed with `cargo install trunk`. -To run it as a server side app with hydration, first you should run +## Server Side Rendering with cargo-leptos +cargo-leptos is now the easiest and most featureful way to build server side rendered apps with hydration. It provides automatic recompilation of client and server code, wasm optimisation, CSS minification, and more! Check out more about it [here](https://github.com/akesson/cargo-leptos) +1. Install cargo-leptos ```bash -wasm-pack build --target=web --no-default-features --features=hydrate +cargo install --locked cargo-leptos +``` +2. Build the site in watch mode, recompiling on file changes +```bash +cargo leptos watch +``` +3. When ready to deploy, run +```bash +cargo leptos build --release ``` -to generate the Webassembly to provide hydration features for the server. -Then run the server with `cargo run` to serve the server side rendered HTML and the WASM bundle for hydration. - +## Server Side Rendering without cargo-leptos +To run it as a server side app with hydration, you'll need to have wasm-pack installed. +0. Edit the `[package.metadata.leptos]` section and set `site-root` to `"pkg"`. This tells leptos that the WASM/JS files generated by wasm-pack +are available at `./pkg`. Building to alternative folders is not supported at this time +1. Install wasm-pack ```bash -cargo run +cargo install wasm-pack +``` +2. Build the Webassembly used to hydrate the HTML from the server +```bash +wasm-pack build --target=web --debug --no-default-features --features=hydrate +``` +3. Run the server to serve the Webassembly, JS, and HTML +```bash +cargo run --no-default-features --features=ssr ``` -> Note that if your hydration code changes, you will have to rerun the wasm-pack command above -> This should be temporary, and vastly improve once cargo-leptos becomes ready for prime time! diff --git a/examples/todo_app_sqlite_axum/README.md b/examples/todo_app_sqlite_axum/README.md index c951fc91d..61228a445 100644 --- a/examples/todo_app_sqlite_axum/README.md +++ b/examples/todo_app_sqlite_axum/README.md @@ -2,21 +2,39 @@ This example creates a basic todo app with an Axum backend that uses Leptos' server functions to call sqlx from the client and seamlessly run it on the server. -## Server Side Rendering With Hydration +## Client Side Rendering +To run it as a Client Side App, you can issue `trunk serve --open` in the root. This will build the entire +app into one CSR bundle. Make sure you have trunk installed with `cargo install trunk`. -To run it as a server side app with hydration, first you should run +## Server Side Rendering with cargo-leptos +cargo-leptos is now the easiest and most featureful way to build server side rendered apps with hydration. It provides automatic recompilation of client and server code, wasm optimisation, CSS minification, and more! Check out more about it [here](https://github.com/akesson/cargo-leptos) +1. Install cargo-leptos +```bash +cargo install --locked cargo-leptos +``` +2. Build the site in watch mode, recompiling on file changes +```bash +cargo leptos watch +``` +3. When ready to deploy, run +```bash +cargo leptos build --release +``` + +## Server Side Rendering without cargo-leptos +To run it as a server side app with hydration, you'll need to have wasm-pack installed. +0. Edit the `[package.metadata.leptos]` section and set `site-root` to `"pkg"`. This tells leptos that the WASM/JS files generated by wasm-pack +are available at `./pkg`. Building to alternative folders is not supported at this time +1. Install wasm-pack +```bash +cargo install wasm-pack +``` +2. Build the Webassembly used to hydrate the HTML from the server ```bash wasm-pack build --target=web --debug --no-default-features --features=hydrate ``` - -to generate the WebAssembly to hydrate the HTML that is generated on the server. - -Then run the server with `cargo run` to serve the server side rendered HTML and the WASM bundle for hydration. - +3. Run the server to serve the Webassembly, JS, and HTML ```bash cargo run --no-default-features --features=ssr ``` - -> Note that if your hydration code changes, you will have to rerun the wasm-pack command above -> This should be temporary, and vastly improve once cargo-leptos becomes ready for prime time!