Skip to content

sachinbhutani/svelte-on-rust

Repository files navigation

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
npm install

...then start Rocket server and Vite 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

Vite

Change Log

v0.2.0: Complete Rewrite

  • upgraded to rust stable
  • upgraded to new svelte version
  • removed rollup, using vite now
  • removed bulma, pure css only.

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