452 points · by danielskogly · 4y ago · 249 comments
I acknowledge that this might be a PEBKAC situation, but I'd love to hear thoughts from people who used Next.js, Remix, or whatever and found Astro to be a revelation.
It seems like Astro's creators believe "content-focused" is a differentiator, but I find that confusing since content-focused sites are a popular use case for web frameworks that are also suitable for more complex apps.
Essentially Astro lets you build sites using a JS framework like React or Vue without requiring that framework to be loaded on the frontend. By default, components are just HTML content. Super nice for building very fast static sites using a technology you may already be fluent in.
You can still add interactivity to components if you'd like—just tag components that require interactivity and Astro will bundle the requisite JS for the client.
Having that productivity and flexibility without the SPA complexity and other JS cruft has real value.
I'm not a web dev by trade but I have a website for a hobby project. I had taught myself React thinking I might make an app. (I never did.)
So now I want to maintain this thing on the side with not much effort using what I already know. And that keeps those skills fresh, which is great.
I'm very interested in Astro.
I think this is the only selling point, given the "content-focused". It's not different than just writing HTML and vanilla js for some interactivity.
With Hugo and Jekyll I always needed to go revisit the docs whenever I hadn't worked with it for a while. I never got to the "oh, I get this tool now" phase, where the content generation could just flow without issues.
Publii was cool, but trying to shoehorn everything into fitting in the "Blog" model never quite worked out for me. Also being forced to work in a new IDE wasn't to my liking either.
Here are some of the things I love about Astro:
- The docs are great. You can read through them all really quickly. I tend to prefer systems that are simple to grok, and Astro is just that.
- The lightweight Astro components (https://docs.astro.build/en/core-concepts/astro-components/) were great for me, because they delivered on being able to create reusable pieces of code very easily (without having to touch React).
- Being able to generate part of your site from markdown and part of it from precisely crafted HTML is a great way to be able to handle both repetitive and unique content.
- The Astro themes (https://astro.build/themes/) are a great way to start. Find something that's somewhat similar to what you want to build and study how they did it.
This is obviously very subjective, but for me Astro was the first SSG that I really enjoy using, and that I didn't feel like I had to fight against.
Why do you hate it? It's useful to have a term to differentiate between the experience of the person using the output of the tool (user experience) versus that of the people developing with the tool (developer experience).
Honestly we need more DX improvements in this industry. Especially look at DevOps - the user experience of Chef's output (I'm picking on Chef here, it's hardly the only offender) is servers and services, and the users (other engineers) consuming those outputs can have a nice time. The DX of using Chef, though, can be ughh....
Nope, we need to roll back everything that happened in the last ~10 years. We at the very least need to stop sticking JS and the web stack everywhere. Use the right tool for the job, NOT pick up a shiny tool and try to do literally everything with it. NOT stumble upon solution and start looking for problems to it. Finally realize that software engineering is actual engineering that, like other forms of engineering, has a sizable impact on other people's lives. Unlike in other forms of engineering, the cost of a mistake might feel diminutive enough, but people do suffer trying to use modern software products. I wish I was joking.
I also hadn't had any coffee in way too long, so I have to admit I was a bit grumpy at the time of writing the comment :)
There is also this page comparing it with other tools: https://docs.astro.build/en/comparing-astro-vs-other-tools
* unless something changed since my last Nuxt project
Might even sneak in a fourth level, "server side, but cached until marked dirty". For when you are set up for static rendering, but want to reduce backend load for rarely changing stuff. I'd expect that it would be quite powerful to have that capability inside the engine that handles rendering, on component level if necessary,and not just on some internal microservice boundary (where I think it's quite common?).
Apparently there has been quite a watershed moment, with the announcement merely a few months ago: https://astro.build/blog/experimental-server-side-rendering/
This gives some more examples of what Astro offers https://twitter.com/matthewcp/status/1557103499724333057?t=8...
It's just a faster way to build UI's that don't need the full complexity of a SPA and also don't need to come bundled with the entirety of react from what I've seen and used it for.
Not really sure when to play around with these new frameworks if it's not giving me enough reason to switch, especially since they're not adopted in big tech companies it makes it harder to justify the usage when I want to build somethjing
I feel that this is what I was looking for https://docs.astro.build/en/concepts/why-astro/
> Next.js uses React to render your website. Astro is more flexible: you are free to build UI with any popular component library (React, Preact, Vue, Svelte, Solid and others) or Astro’s HTML-like component syntax which is similar to HTML + JSX.
> Both Next.js and Astro are frameworks for building websites. Next.js does best with highly dynamic websites (like dashboards and inboxes) while Astro does best with highly static websites (like content and eCommerce websites).
https://docs.astro.build/en/comparing-astro-vs-other-tools/#...
If you need backend api functions - https://github.com/serverless-nextjs/serverless-next.js/ AWS Lambda etc. Probably slightly more work I grant you.
Plus, both Next and Remix are tightly coupled with React, whereas Astro is trying to be more agnostic in that regard.
My biggest issues using it (admittedly in the beta state) were 1) wrong line numbers printed for errors due to extensive rewriting and transpilation without source mappings and 2) no built-in image optimization (there is a third-party tool that works well enough, but for a content-first framework this doesn't seem good enough to me).
[Edit]: Ah, I see in the 1.0 they have built-in image optimization :) I'll have to try that out.
> it’s nearly impossible to sail on your own
Just have to comment that this is plain false (as already evident by dinghy sailing). I've sailed up to 35-footers solo (although I'd advise to stay below 30-ish or 3-4 tons, makes it easier to not crash hard into things). It takes a bit more prepping and does help a lot if you have an autopilot or windvane self-steering (for sail changes and reefing) but it can be done without as well.
And I used to sail my 28-footer solo without an engine.
If you're interested in sailing I recommend checking out Per Tangvald (known as Peter Tangvald). He sailed around the world in his homebuilt engineless ~52-footer for decades, generally handling the boat by himself.
https://wavetrain.net/2016/01/17/sea-gypsy-early-adventures-...
I'd like to check it out.
The big difference here (as with other JavaScript-based renderers) is of course the "use one tool/language for everything" aspect which to me is a bit of a 'meh'-benefit.
At this point, while all the renderers get better and simpler, we're still in a situation where complexity or writing code hasn't really gone away, it just shifted around to new places. Perhaps at some point we get to the HTML + WebComponents stage again (kinda like MDX and React mixing), and classic Apache Server-Side Includes become the new hot thing again.
That said, for most side projects and commercial projects the complexity may not be worth it. It probably makes the most difference to very high traffic sites where money is lost for each millisecond delay in giving you the page (or the ads). And in this sense it may be premature optimization.
I like using Next.js, but I often wonder if it is "too much" and adds complexity I wouldn't have otherwise. An old fashioned rails app, and some caching / CDN done in front of it as a separate concern is probably more than enough performance for most people.
That said, none of the static site renderers really do anything special that is required to do anything on any edge. Considering the huge amount of storage and memory required to store a node_modules tree and re-render on demand, even classic MVC would easily do the same.
What would make a somewhat larger difference might be a combination of factors; something like centralised push and distributed compute via WASM. That means any logic could be compiled and packaged as-is without needing anything else. Somewhat similar to using cloud flare workers with something like Go or Zig.
Then again, like you described with the rails example, this is mostly a solved problem. Even a full server-side view with just classic HTML 4 and CSS output can do this, at very low latencies and very wide reach. After the first hit, the difference between this and static pre-rendered pages is almost irrelevant.
The biggest 'solves' one might get would be uncached always-computed content which needs to be executed on demand, and attack surface changes. But that gives us a different class of problem since we could also decide to simply offload all of the hard work to someone else and simply pay Squarespace and the likes ;-)
You know what's old-fashioned way of doing this? Buy multiple VPS around the world and deploy website files using a script.
Let the experts deal with adding locations, location detection, DNS, redundancy and so on, for a very small price, relatively speaking.
I am not saying you need Astro: You can make the files yourself, then use a service like Netlify to do the CDN-ing for you.
- Templates are plain HTML/Javascript, instead of some other templating language (e.g. Jekyll/Liquid)
- Typescript out of the box
- SCSS out of the box
- Easy remote builds on Netlify
- Scoped stylesheets
- No overcomplicated build process/customization (e.g. Webpack)
- Supports Markdown, YAML, JSON, all the things
- It builds really quickly
And all of that is with virtually no additional configuration. It's great.
Also a big bonus: the team is super friendly and very responsive!
- Tailwind support
- Optional choice of UI framework (React, SolidJS, Svelte etc...)
- Partial hydration. Generates _actual HTML_ on the server-side rather than JS blobs (which is what some other frameworks call SSR).
It really does work nicely. It's very fast, minimal config required.
We generated page partials (or used static ones) and pulled them in with "Ajax" (for the oldies out there) and then inserted them in the right place on the page using innerHTML.
There's nothing wrong with this coming back around, it worked quite well!
It's just amusing how some things come full circle and are now considered innovative again. I'm sure there are advancements under the hood of course.
And it's not quite the same thing - we're not talking about injecting server-side HTML snippets into other HTML pages (which never actually went away). This is more like optional, self-contained but fully-featured web applications that load after the full HTML renders. You could use that to fetch static HTML, or you could use it to provide an interactive client-side experience that only operates on a portion of the page, up to whatever complexity you like. And if the user has JS disabled the rest of the site still renders correctly.
https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.up...
Vercel is not much better at 10 users, and they hide it deep within their pricing table behind a tooltip so you're not likely to realize this until it's too late.
Cloudflare Pages doesn't charge per user but limits concurrent builds which can get really painful.
I honestly can't find a good option in this space anymore... What happened?
They took lots of VC money, got crazy valuations and picked up a few enterprise customers as the JamStack trend grew - and now have to try to generate a return.
and for private orgs https://www.netlify.com/pricing/private-org-repo-faq/
> This vision of a better web is why Netlify is bullish on Astro
can't this horrible stock market and crypto bro lingo stay in the casino bubble.
import { createApp } from 'vue'
import { Quasar } from 'quasar'
app = createApp()
app.use(Quasar)
But since astro abstracts away the root Vue application, I don't see how this is possible anymore.Astro might make sense for a blog where you don't need a full blown component library but for any other web application, I'm skeptical of its capabilities.
But when I create a website now, I got to stick with Wordpress because they are easier to sell and non tech people can use it.
To try Astro on your local machine, run npm create astro@latest in any terminal.
because it doesn't make it clear to me what to do before this command will actually do anything. No, running this command will not work in any terminal.This particular example isn't too bad -- looking at that line, it would be clear to me that I'm missing 'npm', and the solution is obvious -- find out what npm is, and get it installed. But the things that really bit me were tons of examples of JavaScript, which included strange lines like 'import', and I had no idea how to get my website's JavaScript to understand what an import is or any of the other syntax. Nothing would work! I didn't realise there was a whole ecosystem around how to build your code so that it can make use of these things. Every guide assumed I had things going, and I just didn't understand that I needed this other infrastructure in place first before I could do anything.
[1] https://peterxjang.com/blog/modern-javascript-explained-for-...
Some notes of things that have changed in the last five years:
- bundling is (almost) no longer needed for simple import/export as we now have a native module capability (esmodules). The biggest issue you’re likely to have here is waiting for any dependencies you have to upgrade from common js to esmodules.
- transpiling is not as necessary unless you explicitly have to support IE11, or require something in the latest ecmascript spec.
It really speaks to the maturation of front-end development that after five years that article is still fairly accurate.
About time too - I’m too old to put up with that level of churn anymore.
Exactly proving my original point.
Take a look for example at the rust installation steps [1]. They tell you to run the following command in your terminal: "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh". They don't tell you to first make sure you have curl installed (or sh for that matter).
Seriously, JS static website generators are the worst... use something written in any compiled language so you just download and run a single binary, no messing around with npm and millions of dependencies.
Take your pick here: https://jamstack.org/generators/
I agree; the "in any terminal" part is paternalistically redundant - any software developer who recognizes the npm command will know what to do with it.
the reason node based documentation sucks so bad, is that generally by the time you read it, it's already deprecated.
s/
The site has about 20 categories, and each category has about 100 images. Every time the team adds a new image or category, the deployment/building task clones the repo and then the build process generates all the optimally sized images again and then re-uploads multiple gigabytes to the host. Is there a way around this type of problem with static site generators?
And of course any framework where SolidJS can shine so bright is going to be the top of my list.
Congratulations on an amazing release.
Is the difference in page loading speed really that significant? SolidJS or Svelte apps with lazy component loading are already pretty fast - Ryan Carnatio has shown some benchmarks on his Youtube streams where the differences are in the ballpark of around 50-500 ms IIRC. Is it a mobile client thing? Or more like "We are Amazon and every 0.1 seconds waiting for the page some xyz customers leave and therefore costs as quite some money"?
I mean, those frameworks are really complex. Is it worth it if you already use a fast and small SPA framework like SolidJS or Svelte?
> Astro works with the tools you already love, but this requires a lot of effort to get right. Luckily, Astro is supported by some amazing partners across the industry who support our vision for a faster web.
Fast/easy content-focused websites are a subject dear to my heart but far from my day-jobs, so I'm always happy to hear about people making the thing I never quite finish making.
But the above quote is... weird?
The first thing "people" are saying about Astro is it's a pain in the butt, however "luckily" you can spend money on companies to make it less so?
Not very clear, agreed.
https://docs.astro.build/en/comparing-astro-vs-other-tools/
"Both XXX and Astro are frameworks for building websites. XXX does best with highly dynamic websites (like dashboards and inboxes) while Astro does best with highly static websites (like content and eCommerce websites)."
This explanation is used for every XXX framework, but i can't really see why. With components you can show high dynamic data, so for me there is no difference if i use XXX or Astro.
Did somebody has some real life examples, that could explain the difference?
Or why it could be better to stay with XXX and not use Astro.
Currently we want to switch our svelte project to SvelteKit, git rid of our custom fiddle (router, etc.). But when i see Astro now, i think about what speak against using Astro? But at the moment it seems that it has many additional benefits?
They compare Astro to Docusaurus, Elder.js, Eleventy, Gatsby, Hugo, Jekyll, SvelteKit, Next.js, Nuxt, Remix, VuePress, and Zola.
(For some reason, this page doesn't appear linked anywhere from their documentation's table of contents, and isn't even linked from the "Why Astro?" page. It's almost like they're trying to hide it or something!)
As an avid user of Gatsbyjs I can say that people don't see that the graphql usage in that tool is the medium not the end for the sake of having graphql.
In fact Solid's creator has said Astro is probably the best way to do SSR with it.
I've been looking to make a simple website recently - landing page, user sign up, taking payments, then access to a simple react one-pager. It's all doable but with django you just have to do everything, even if you start with the cookicutter.
I just want something where I can pick from a good base template, then get started, not spend days plugging all the parts together. If this helps with that I'll check it out. What would you use for the user data? Firebase, etc.?
And I don't think the static site generator is the driving force for complexity here. The web ecosystem really seems nuts when you step back. When it comes to publishing on the web, I would really like to see something simpler gain traction.
Browsers are both amazing and amazingly complicated. I would like to see the 80/20 rule applied to see what comes after HTML -- maybe a reboot for 2023?
Surely I'm missing something that already exists?
The ability to totally not send any JS at all apart from what you manually add such as framework specific components is really something.
Plenty of applications in the second category (logged-in admin dashboards, to-do lists, etc.) have been developed using server-first frameworks, and some of us still prefer to develop web applications that way. Is Astro missing any key features for dynamic server-first applications, e.g. form submission and validation support? If not, I think the Astro developers might be selling Astro and MPAs short.
That said, there’s quite a lot of space between that extreme and the mostly-static “web site” extreme, and I agree Astro would be a better fit than they let on, for a large chunk of that space. My suspicion is that this is intentional, to keep their current focus and explicit use-case commitments narrower. And I wouldn’t expect it to remain that narrow in the future.
So we're back to multi-page websites now? K.
I'm still writing my html and CSS by hand.
Qwik City[1] is probably more directly analogous to Astro, Qwik being more analogous to Astro’s integrated renderers. But that highlights one of the key differences.
Astro’s compiler mostly focuses on server rendering of static content (.astro templates, MDX) and bundling client resources along with the logic necessary to hydrate islands. Astro defers to those renderers (and in some cases their own compilers) for any further optimization of the client bundle.
Qwik’s compiler optimizes the component code directly, serializing state into the HTML it renders server-side, for the client bundle to resume from that state. Its output is conceptually similar to Phoenix LiveView (which was mentioned in another sub-thread).
Both are compelling approaches. I think Qwik’s will probably (eventually) have an optimization advantage because that’s a core focus of the client library. Astro will likely have an adoption advantage because it’s client-library-agnostic.
Another framework in the space often gets passed over: Marko[2], which has been doing partial hydration for years at eBay. Marko is probably more similar in approach to Qwik (and as I understand it, getting more similar as they’re going resumable too), but like Astro has its own templating language which enables its compiler optimizations.
Also worth watching SolidJS[3] (whose creator has also worked on Marko), which is tracking partial hydration/resumability on its roadmap. I’m not sure what their approach will look like but there’s quite a lot of insight both in the issue and the creator’s tweets/replies on the topic.
Personally I think there’s a gap between all of these approaches which could leverage type-level analysis to go much further. But that isn’t really feasible when types being available or accurate isn’t a safe assumption.
Might try this out at some point.
I like working with TS, JSX is fab, and I never enjoyed Hugo or Jekyl. Next.js is nice but too much for this case. Gatsby is not nice and doesn’t do much. Astro sounds just about right.
Or if you mean what was astro itself written in, I think this post is aimed at users of the system, not potential contributors. Personally I dislike it when when a post says something like "Hugo, a static site generator (Golang)" because it incorrectly implies you need to write Go in order to develop with it.
Simple to use, blazing fast results. JSX. Use another framework you like inside it (e.g. React, svelte).
Could you please explain the tradeoffs vs tools like Hugo and Docusaurus?
The format looks identical to MDX
Open your browser devtools, pick a random tag on the page, add "client:load" to it, and then "console.log(yourEl.properties)"
I dunno why you need an entire custom filetype for behavior and semantics that are MDX with a few extra preprocessor rules
.astro is not actually like MDX at all. MDX extends Markdown, Astro does not, it extends HTML. MDX is a variant of JSX, Astro is not, it supports things that JSX does not like void elements. Astro supports text inside of script and style tags, JSX does not.
If you think you can rebuild Astro with "a few extra preprocessor rules", then by all means go for it. But you're going to fail.
inevitable question that always can use answering - what can you share about Astro's company business plan/business model at this time?
Inevitably, when a new "hot" SSG comes on the scene, I try it, and then go back to compare it to the old "hot" SSG from 2 years ago. Yet, I can never get the old test site I set up running again without massive annoyances. This has happened multiple times.
As far as I'm concerned, there's zero reason your landing pages and blog should require 3,000 dependencies to run.
And like all SSGs, I see no mention of sane SEO defaults on the homepage. Let me guess--with Astro I'm going to have to set all of this up myself?
Pin your dependency versions and never suffer this problem again! Shrink-wrap your node modules and don't even download them again! Use Yarn's offline cache to share package tarballs between applications to save on disk space!
There are many options for this problem. And that's just in the JS ecosystem. Use something Ruby or Go based and it's even better.
As far as I'm concerned, there's zero reason your landing pages and blog should require 3,000 dependencies to run.
Except there really, really is. A static site generator is really an optimizing compiler for 4 or 5 different languages (html, css, js, markdown, a template language, etc), with a build tool chain, and often image optimization, and a server for dev, and usually some sort of semi-opinionated structure that scans a directory tree and magically turns that into something you can just throw up to a web server and have a working website. They're complex systems pretending to be "simple and easy" because the output is essentially HTML with a few whistles.
You certainly can build a site generator with far less code, but when people want a lot of flexibility just by tweaking a JSON config file that necessitates complexity. And in JS, that means more packages.
The beauty of tooling is that there are lots of alternatives if you feel you want to optimize for dependencies instead.
I am experimenting with Caddy's template functionality [0] in my pursuit of making dependency-free and buildless websites. Caddy's templates are inspired by the Server Side Include (SSI) functionality in Apache and Nginx, except it uses Golang's syntax. I have made several websites in Hugo and find it pleasantly similar, only more bear-bones.
Although Caddy is serving static sites to the browser, it is technically more like using a dynamic scripting language like PHP on the server. I guess Caddy templates outperform PHP by a large margin because it is written in Golang and compiled, but I have never tested this hypothesis.
Funfact: Caddy's entire website is written with Caddy's template system and the source code is available [1] for those who want to take a look!
[0] https://caddyserver.com/docs/modules/http.handlers.templates
I don’t see a reason to switch a site from one to the other if you and any collaborators are comfortable maintaining the runtime. The same goes for JS based tooling (I imagine), I just don’t node so good.
Personally, I use Hugo for new projects because it lowers the burden for content collaboration.
Templating is weird in Go, though if you’re working on themes. I like it now, but it’s procedural vertically and LISPish horizontally, if that makes any sense.
Usually it’s just me or me and another guy messing with that, and others often unfamiliar with anything except Java contributing vanilla markdown documentation. “Clone the repo, run this binary” is helpful there.
But like sibling said, if you're happy with your setup, keep it.
Commonly stated but not actually true. For example:
https://github.com/getzola/zola/blob/master/Cargo.lock
https://github.com/gohugoio/hugo (scroll to the bottom of the README)
Plus as sibling comment says you usually don't do anything but install hugo, `hugo [command]`
Much of the interesting and useful tooling today is in the JavaScript ecosystem, that you will still have a package.json, Node dependency, etc. Except they are not Hugo’s problem, they arrived via a theme you are using, and they are your problem.
Hugo itself is a pretty lean template system. That means it doesn't know much about building websites. All kinds of things you hope it will know about (SEO, how to plugin analytics systems, much much more), are sitting over in themes in the ecosystem… tangled up with the axis of what visual appearance you want.
So the notion of swapping themes to swap appearance doesn't work, because the theme you picked provides a bunch of functionality in addition to appearance, and a different one will not have the same functionality.
This isn't a complaint, it is a good piece of work with many well-thought-out ideas. But it is pretty far from what the poster was looking for.
After spending a little time understanding Go templating it is really beautiful
Also figuring out the variable structure took me a bit, but now the docs make sense to me.
My theme is super simple. A few templates, 1 CSS file, and a tiny amount of vanilla JS. I just let Hugo + CSS do most of the lifting.
I think some folks have had bad experiences with themes that layer a JS framework on Hugo, though. That may be a better case for a completely JS ecosystem.
There’s a lot of good options. That’s a good problem to have. Just use what you like, I guess.
1. I've not yet had issues building old sites
2. Just in case you anticipate such issues you can just check the binary into your repo
It's a static blog generator type thing, bit of a different concept to the framework posted. I've tried it a few times casually and it seems ok for non-devs to get something simple up and running. Bit of dev work can update templates etc
The SEO defaults aren't perfect but they're easy enough to change in the software.
That said, it may require a bit of javascript knowledge to get a more customized build running. It does have YAML configuration and a set of useful plugins you can use without touching code, from what I know.
Not sure how you'd get away from a build on updates though, it is called a static site __generator_. If you want to skip the build entirely, just write .html files and call it a day.
If you don't want the trouble, don't chase the new hotness. Use what works until there's a compelling reason to switch.
My overall impression is: use 11ty for a first version, use Astro when you have more moving parts on the frontend.
Little bonus for those coming from Python background (like me): 11ty uses Nunjucks, which is a JavaScript port of Jinja, so the templating system feels right at home.
Use Zola or Hugo. They have zero dependencies.