/svelte-on-rust

Svelte on Rust starter template

Primary LanguageSvelteMIT LicenseMIT

Svelte-on-Rust

Starter template for Svelte frontend apps with Rust Rocket backend server.

Requirements

NodeJs - Install

Rust - Install

Rust Nightly for the project folder

Get started

Create a new project based on this template using degit and install the dependencies...

npx degit sachinbhutani/svelte-on-rust svelte-rocket
cd svelte-rocket
rustup override set nightly
npm install

...then start Rocket server and Rollup in two different terminals

Terminal 1: (To run the rust server)

cargo run  

Terminal 2: (To build and hot reload svelte components)

npm run dev  

Navigate to localhost:8000. You should see your app running. All svelte component live in client directory. Save any changes live-reloading. All Rocket code lives in src directory. To rebuild Rust code use cargo run after saving your changes. All static files are served from public direcotry. Including the JS code compiled by Svelte Compiler.

Building and running in production mode

To create an optimised version of the app:

npm run build
cargo build

Built With

Rocket

Svelte

YRV

Bulma

Change Log

v0.1.4: update packages because cargo run failed

v0.1.3: Added authentication example with private cookies

v0.1.2: Added Bulma CSS styling