Git Product home page Git Product logo

rust_fullstack_template's Introduction

Rust Fullstack Template

This repository contains a template for a fullstack Rust application. It is based on these technologies:

  • leptos for the frontend, including:
    • reqwest for HTTP requests
    • serde and serde_json for JSON serialization
    • anyhow to easily handle errors
  • rocket for the backend, including:
    • serde and serde_json for JSON serialization

Additionally, the project contains a shared library that is used by both the frontend and the backend. In this library you can define shared data structures, like data transfer objects, and functions. It also uses serde and serde_json for JSON serialization.

The whole project it configured as one workspace containing all three projects.

install nightly rust toolchain and wasm target

The frontend uses nightly features and compiles to WebAssembly, so you have to install the nightly toolchain and the wasm target, if you haven't already.

rustup toolchain install nightly
rustup target add wasm32-unknown-unknown --toolchain nightly

The same commands can be used to update the toolchain to the newest version.

set workspace to nightly build

The frontend uses nightly features, so you have to set the workspace to nightly build.

rustup override set nightly

how to run

You have to start the frontend and the backend separately.

run backend

Go into the backend directory and run the following command:

cd backend
cargo run

It will launch the backend using the Rocket library. The default port is 8000.

If you want hot reloading, you can run the backend with the following command:

cd backend
cargo watch -x run

run frontend

Go into the frontend directory and run the following command:

cd frontend
trunk serve

It will launch the development server for the frontend using the leptos library. The default port is 8080. In the file Trunk.toml, the proxy for the dev server is configured such that every request to /api is forwarded to http://localhost:8000/api.

The frontend is run with hot reload.

Open the browser and go to http://localhost:8080. You should see the text "Hello from backend" that is fetched from the backend via an HTTP request.

rust_fullstack_template's People

Contributors

goetz-markgraf avatar

Stargazers

M. Sezgin avatar Ferdinand Swoboda avatar Sebastian Schuberth avatar

Watchers

 avatar

rust_fullstack_template's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.