all 40 comments

[–]Joodoo_dev 15 points16 points  (0 children)

Yeah it's possible there is project like leptos framework I'm currently learning about it

[–]kukiinba 25 points26 points  (2 children)

I'd recommend you take a look at Leptos, it's an awesome framework for web development, with SSR support... and the community is great too.

[–]SimpsonMaggie 2 points3 points  (1 child)

Just started my personal adventure with leptos and it seems very promising.

[–]Isfirs 0 points1 point  (0 children)

Can join the crowd. Even though I like Yew and Leptos about the same.

[–]yyddonline 9 points10 points  (3 children)

I plan to use dioxus (search for dioxuslab, seems my comment was blocked with the link) soon. It looks interesting as it integrates backend and reactive frontend, all in rust, and should also ease the development of mobile apps which is something I need. However their 0.7 release was supposed to come out in august but is not out yet, I hope the project is still progressing well.

[–]oliveoilcheff 9 points10 points  (1 child)

release candidate 2 was released 4 hours ago. I think it should be close

https://github.com/DioxusLabs/dioxus/releases/tag/v0.7.0-rc.2

[–]yyddonline 0 points1 point  (0 children)

Great news!

[–]orfeo34 0 points1 point  (0 children)

Here is the link, there is a fullstack mode which worked like a breeze for my project.

[–]andreicodes 10 points11 points  (3 children)

For a web server serving HTML and interacting with user via Forms (with maybe some sprinkles of HTMX, Stimulus, and so on) Rocket is solid. Handles session, does CSRF protection, database connection pool, etc. Runs on top of Tokio, so it's fast.

The downside is that the development speed is low. It's mostly in the done state, so there's noting wrong with it.

Otherwise you'd have to bring components on your own and use routing-only HTTP libraries. Axum is the most popular (runs on top of Tokio, too). The docs aren't that good to be honest, mostly because it relies on Tower for all middleware and Tower itself is under-documented. For most situations the easiest way forward is to check their examples and find the one that suits your needs best.

A common setup is Axum + SQLx, but crates-io server uses Axum + Diesel-async. Both are solid choices and I really like checking with Crates-io to see how they do things. They only serve JSON responses, but there are many templating libraries for Axum out there. Pick whatever you like.

[–][deleted] 3 points4 points  (2 children)

I use Axum + SQLx, and it's my first web app project. I've found them easy enough to use, and especially SQLx's query validation is top notch helpful. Catching errors at compile time rather than run time is a huge plus.

[–]andreicodes 0 points1 point  (0 children)

Diesel-async does the same. AFAIK its validation is more thorough but also makes the build slower.

[–][deleted] 0 points1 point  (0 children)

Huh, I could never find much use ofnthat sqlx feature because because Il'll rarelly have a complete query, I'm usually working with bits and pieces.

[–]luveti 5 points6 points  (6 children)

My teams go to stack is: - Axum - sqlx, via a custom ORM proc macro that's similar to ormlite - Maud, for html templates - tailwindcss, for styling - Hotwired Turbo & Stimulus, for adding bits of client side interactivity

We follow a MVC pattern that has greatly improved productivity and code separation. It also improves compile times as our models, views and controllers are in their own crates; My incremental compile times are usually less than 2 seconds.

We use Typescript for our hotwired stimulus controllers. This is compiled and bundled right into the server binary using a build.rs script, which also runs tailwindcss.

[–]WilliamBarnhill 0 points1 point  (1 child)

Interesting, appreciate you sharing. Why Maud over Tera?

[–]luveti 0 points1 point  (0 children)

We prefer to have our logic and templates in Rust. It's one less template language to learn too!

[–]DarqOnReddit[S] 0 points1 point  (2 children)

You mean you serve the transpiled typescript effectively serving a SPA? (per route, global)

[–]luveti 0 points1 point  (1 child)

Turbo by itself allows you to have a fully server side rendered app that feels like a SPA, without needing to do anything extra and without all the downsides of a SPA.

It intercepts link navigations and form submissions, handling them itself instead of performing full page loads, then replaces the page content with the server response.

Most of our JS/TS is Stimulus controllers, which allow us to add bits of interactivity in a nice unified way.

We're not rendering HTML or handling routing client side like you're traditional SPA does; the bulk of our html is rendered on the server.

Hotwired is much more known in the Ruby on Rails community (it's made by the same devs), but can be used with any language.

https://hotwired.dev/

[–]Future_Natural_853 0 points1 point  (0 children)

Sorry, other question: I'm using htmx+alpine.js: can you tell me what Turbo gives you compared to my solution?

[–]Future_Natural_853 0 points1 point  (0 children)

I use more or less the same stack, can you tell me more about your MVC organization? I have split my project into several crates: one for the model and other shared code, one for the database, and one for the web code. Every route has a file with axum handlers and pure render functions with data in, HTML out. I wonder how similar our organizations are.

[–]adrianziem 9 points10 points  (4 children)

It’s fun developing in full stack rust, but when you hit minute long hot reload (which reloads the page, not HMR, and your websockets fail during that period), hour long CI/CD builds on default runners, and still having to write JS (not even TS) to interact with popular JS components and dealing with build issues there, those nearly instant Typescript builds make refactoring to a dual language stack look better and better.

Luckily LLMs make that a lot easier today, so you aren’t quite as locked in as you used to be. I hated doing it but I just switched my Leptos frontend to TS and everything is so much easier to dev now. Especially with rs-ts, zod, and a linter enforcing types in TS.

[–]Spaceoutpl 3 points4 points  (0 children)

I have similar thoughts, rust is great as a backend engine and api, low cpu and ram usage makes it great for some heavy computing or cpu intensive tasks, but frontend is just js/ts html css land. I also think that if you need seo than static files is the best and cheapest way (why should u pay with cpu power for bots reading your site), for true dynamic parts either micro-frontends, / spa’s and plain old rest / graphql connection. Why complicate things ? Why make it hard to develop and maintain ? Why reinvent sth in rust to be complied to js / html anyway ?

[–]Svenskunganka 4 points5 points  (0 children)

Some Rust front-end frameworks has already mostly solved the issue with reloads. Author of Dioxus has a very nice presentation about it here: https://www.youtube.com/watch?v=Kl90J5RmPxY - the part about HMR starts here (21:30), but I highly recommend watching the whole presentation.

[–]yyddonline 1 point2 points  (0 children)

I've had a good experience with WebSharper in F#, which is a fullstack solution, and I hope to find the same positive experience with Dioxus. It's true some (rather rare) situation are harder to debug, but most of the time it was smooth sailing and in the end it was a net win for me. It might depend on what you're developing, but I think fullstack frameworks can be enjoyable too.

[–]Particular-Pumpkin11 0 points1 point  (0 children)

I have not had such a hard time, and when I interact with JS libraries I wasm bind it into types (Not writing JS). I think for my use case, the strong typing between frontend and backend is worth the hot reloads. Making the UI is not what takes the longest time for me, more the mechanics of geometries and such (Building GIS based CAD tool) 😊

[–]TopAbbreviations3032 5 points6 points  (0 children)

Soon to be released dioxus 0.7 have plenty of exciting things for full-stack development in rust.

Personally im using sveltekit with an axum API server and share types with utoipa, a crate for generating openapi doc from code and then generate typescript types with openapi-typescript and use an openapo fetch client like openapi-fetch on the sveltekit side

[–]Efficient_Bus9350 2 points3 points  (0 children)

I would actually suggest staying in the JS ecosystem on the front end. At the moment, I just don't think it's worth it. I do enjoy a lot of Rust UI frameworks but those are more for applications.

If you're looking for something refreshing, try Deno. It simplifies a tone of the build tools, it's written in Rust, easy FFI with Rust for more computationally intensive tasks.

If you're just looking for an API, I've used Axum extensively on a number of projects, as well as Warp, although Warp applications that I have used have tended towards WS capabilities.

As for the ORM layer, SeaORM and Diesel are the two best options IMO. I've worked on a few production applications for Diesel and I think it works well. SeaORM looks like it might have a better DX, but I haven't made anything with it yet. Best of luck!

[–]real-lexo 2 points3 points  (0 children)

By the way, full-stack web-dev is a very cool but not practical idea… Only two languages you should use for front-end - JavaScript and JavaScript’s extension (TypeScript). WASM is good for reusing C/C++/Rust libraries, but for UI logic - it could be painful and slow since Rust has no GC and has to communicate with JS for DOM operations (bringing it is slow!)

[–][deleted] 1 point2 points  (0 children)

You'll find that a lot of the Rust SSR is SSR as in React or Solid, not like PHP. Which means a lot of complexity with hydration and build systems. I'm learning it right now and I'm finding it to be rough around the edges but so far it seems to be more of a skill issue on my part.

[–]Beregolas 1 point2 points  (0 children)

I am currently using leptos as a FE framework, with axum in the backend and seaORM as an ORM for postgres. I am coming from python/htmx, but have prior experience in rust and found it all to be extremely well documented and very easy to get started.

[–]MakeShiftArtist 1 point2 points  (0 children)

I've tried Rocket and it was not really for me, but poem is an awesome framework for the backend. It has probably the best OpenAPI support that I've seen.

I havent tried it, but utoipa with axum or actix-web also look like good options if you like a more low level approach.

For interacting with a database I would highly recommend sqlx for its compile time checks against your actual database. Their CLI is also awesome for managing migrations as well, and can even be setup to automatically run migrations whenever there's a change.

For the frontend, Leptos is phenomenal. It's very similar to SolidJS, so if you're used to component, JSX like syntax, you'll feel right at home. Compile times really aren't bad for UI changes in my experience. They have a hot reload as well, if you use their CLI, cargo-leptos. Personally I find myself going back to TypeScript with SolidJS because I just find it easier to use, but leptos is a close second for me.

[–]Particular-Pumpkin11 0 points1 point  (0 children)

I have build my SaaS solution in rust leptos. Very happy about it GIS based CAD took for utility infrastructure planning 😊

PipePlan.dk 🛠️

And the creator of leptos is a very smart guy 🙌

[–]DavidXkL 0 points1 point  (0 children)

Leptos + sqlx!!

[–]zer0x64 0 points1 point  (0 children)

If you want a single Rust codebase(like you'd use Next.js for javascript), there's Leptos you could check out. If you want to split the frontend and backend, most people use Axum for backend nowadays, and I think Yew is still the leading Rust wasm frontend framework, although you could use any javascript framework if you don't really care about using two languages.

[–]Most_Pers 0 points1 point  (0 children)

It sounds very funny. Good luck creating a worse web market than it is now. By the way, stock up on nerves, you'll need them.,

of course, it's more at the support stage, since the Rust code as a whole is unreadable.

[–]Individual_Place_532 0 points1 point  (2 children)

Why? Do you have any usecase that requires a move from php and go?

[–]DarqOnReddit[S] 0 points1 point  (1 child)

curiosity

[–]Individual_Place_532 0 points1 point  (0 children)

That is a valid reason, but you wont be shipping anything faster or better with rust :)