Hacker News new | ask | show | jobs
by klabb3 631 days ago
> I love web dev using rust! I use sveltekit and proxy all requests to /api to a rust backend

I think this most people would call this backend-, api- or service development. Especially if your api endpoint does not do anything web specific except http.

Anyway, how do you share types between the backend and frontend? Are you rawdogging json?

2 comments

Rust could probably generate the HTML.
I've been playing with loco.rs to do this! Really cool, let's you use htmx or sveltekit (or whatever you want)
Sounds interesting! Do you have an example project? It seems to be quite opinionated.
Yeah quite opinionated! I don't have an example project at the moment, but here's a youtube video from loco.rs that someone might find interesting: https://loco.rs/casts/007-htmx/
Yeah, that makes sense. I've only had fullstack web dev jobs using node, thus the phrasing but you're totally right.

I use the ts-rs crate, which adds a derive(TS) macro for types in rust and generates typescript types. It works so far but my side projects are only medium sized. But I'm sure there are other options too.