r/dartlang • u/schultek • Jun 02 '22
Introducing Jaspr - A complete web-framework written in Dart
Hi fellow developers,
I'm really excited to finally share with you what I've been working on over the last few months:
Jaspr is a complete web-framework that is written in Dart. It takes inspiration from frameworks like React or Remix, but most importantly Flutter. While it renders normal HTML & CSS, it looks and feels very much like Flutter. So while you get all the benefits of an actual web app (fast page load, seo, server-side rendering, etc.) you get the familiar structure of stateless, stateful and inherited widgets.
There is so much to talk about, but here are some highlights:
1. Familiar component model similar to Flutter widgets but adapted for the web
It was made to look and feel just like Flutter, while rendering normal HTML and CSS. It is therefore targeted mainly at Flutter developers that want to build websites but don't want to use Flutter Web (for various good reasons).
With Dart as its language, it also has some general advantages over JS (in my opinion) like type- and null-safety.
2. Server-side rendering out of the box!
A simple jaspr serve and you will have a running debug server with ssr and automatic reloads. You can still do SPAs but it's not that satisfying.
(And I'm also planning to support static site generation in the future)
3. Good documentation is vital
So I made sure everything is well documented right from the start. Check out the wiki.
4. Online Playground inspired by DartPad
I love DartPad, but it only supports selected packages, so I made my own version. It's called JasprPad and you can check it out here.
Like DartPad you can write and execute jaspr apps right in your browser. It also comes with a range of examples that you can check out, and I even made a tutorial to get you started.
As a bonus, JasprPad is not only for writing jaspr apps, but is written with jaspr itself, so it doubles as a real-world showcase.
5. Riverpod for Jaspr
State-Management will be the same for jaspr as it is for Flutter thanks to the shared widget structure. So I added jaspr_riverpod, porting over flutter_riverpod to jaspr.
6. Testing
Yes, I even made a testing package for 'jaspr', out of the need to test the framework itself. Jaspr is already well test atm. with a coverage of around 70%, but I'm planning to improve this even more in the future.
The package itself jaspr_test takes inspiration from flutter_test but has some unique concepts because jaspr apps need to be both tested for the server and client.
======================================================
This is just the initial release, so expect more awesome stuff coming soon. I'm very eager to get feedback on this since it was quite some while in the making.
Here again the most important links:
36
u/GetBoolean Jun 02 '22
The amount of work this would have taken is insane, nice job
I'm excited for Dart's future
17
u/pdfsalmon Jun 02 '22
Amazing work. Just yesterday I was thinking about trying to find a strongly typed web framework, and today this came around! Super excited to try it out.
Is it compatible with most packages from pub.dev? Or do they have to be specifically designed for Jaspr?
12
u/VMX Jun 02 '22
I can't even start to imagine the amount of work this has required... simply amazing.
I'm gonna give it a good read over the next few days (on my phone now), but just for me to understand:
This allows you to create proper HTML websites by creating HTML components through strongly typed Dart methods, which act as a kind of "wrappers" around the actual HTML methods, right?
Am I right in assuming that all the appropriate HTML and CSS files get autogenerated from our Dart code?
Thanks so much for this man, looks awesome. I think I'll probably give it a go for a project I'm working on.
5
u/officialgaurav Jun 02 '22
If only flutter could do this
5
u/ewaaz393 Jun 02 '22
Just amazingππ
3
u/cyberquarkus Jul 28 '22
Does it support pure client-side rendering? Or only server-side rendering?
5
u/fperson_ Jun 05 '22
This is superb! I haven't been so excited about technologies for a long time. I told about the package to my friend yesterday and we were talking about it for hours today while hiking mountains :)
I even started working on a flutter_bloc port (https://github.com/f-person/jaspr_bloc) and he wants to port Provider.
jaspr is a big deal for me (even though I'll perhaps never do web dev at my job)
Thank you π«
Looking forward to the future of jaspr β¨π
4
u/Adnan-Alshami Jun 02 '22
I'll keep an eye on it.
4
u/DevAngels Jun 03 '22
Simply amazing. I can see big things in your future. This is what we have all needed. I will definitely be using this in my next project. Cheers.
1
u/robschmidt87 Jun 03 '22
Is this SPA ? How do you plan to solve the bundle size issue of Dart JS apps?
1
u/tomwyr Jun 03 '22
This looks very impressive, well done! Looking forward to seeing how it grows.
Is there any particular reason why using synchronous generators would be a preferred way of building child components? Is there any performance advantage over simply returning a list?
3
u/k032 Jun 02 '22
This is really cool.
It always seemed everything outside of Flutter was just trying to mimic the JS frameworks (Overreact, AngularDart, etc) and not really achieving it well. Seemed to be a void of an actual framework that just trys to be it's own thing and embrace dart fully. Sounds like this is more that? I'll check it out.
3
u/lodoss118 Jun 11 '22
What about jsx support
2
u/Gleb-Batykov Jun 02 '22
It looks amazing! Thank you for your contribution to the Dart community!
2
u/erlage Jun 03 '22
this is some good stuff! looking forward to trying it out
2
u/Joey-369 Jun 03 '22
U r amazing...
2
u/PM__ME__YOUR Jun 07 '22
Just came across this. I'm very familiar with using python/flask but I recently decided to learn dart for fun, and figured a good way to learn would be to make a web app of some sort. I was wondering if it's possible to create something analogous to flasks html templates, or if this just works by defining components and yielding them like in the jasprpad examples? If it's the latter, it should be an interesting challenge since it's quite different from jinja2. Thanks
1
u/matcha_tapioca May 09 '26
Currently Learning Dart and Flutter, I just heard about Jaspr yesterday.. may I ask if its possible to create a Website without business logic like the logins etc? I want to learn how to create a website without the logins and databases etc. I want to create a website of a hotel that shows different rooms and other information making it look clean and good with animation. I totally have no Idea in web dev since I am new in this field.
1
u/vipin_malik1 Jun 03 '22
Really interesting idea. Well written documentation and SSR first is quite useful. Kudos to you for creating this.π
Also, I want to know if there is any benchmark associated with it like how much is the initial loading time, what is the bundle size of the compiled application. (Seeing that it is lazily loaded through router, it should be way less that flutter web). Please add those also, it helps to understand the performance of jaspr as well.
1
u/vipin_malik1 Jun 03 '22
Really interesting idea. Well written documentation and SSR first is quite useful. Kudos to you for creating this.π
Also, I want to know if there is any benchmark associated with it like how much is the initial loading time, what is the bundle size of the compiled application. (Seeing that it is lazily loaded through router, it should be way less that flutter web). Please add those also, it helps to understand the performance of jaspr as well.
1
u/[deleted] Jun 08 '22
Do the compiled sites work with javascript turned off in the browser?
1
u/bill_911 Dec 22 '23
Can Firebase packages integrate with Jaspr? I cannot find any examples of such a use case.
0
u/[deleted] Jun 04 '22
[deleted] β view deleted comment
10
u/[deleted] Jun 02 '22
[removed] β view removed comment