Astro 1.0 – a web framework for building fast, content-focused websites
astro.build
astro.build
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.
Plus, both Next and Remix are tightly coupled with React, whereas Astro is trying to be more agnostic in that regard.
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.
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.
A basic counter component would look something like this:
initial_state do |props|
{ count: 0 }
end
handler(:increment) do |e|
update do |count:|
{ count: count + 1 }
end
end
render do
<div>
<p>Count: {state[:count]}</p>
<button on-click={handler(:increment)}>Increment</button>
</div>
end
There are some things I'm used to in the JavaScript world that I'm trying to introduce here. I got hot reloading which is pretty cool. And CSS modules... and static typing with Sorbet.Events are handled on the server, so there's no need for an API... You could just talk to your database directly in your onsubmit-handler. I think that might be the largest benefit from using something like this.
If the app is deployed in a region close to you, you won't barely notice the latency.
I mean if JSX is considered as something particularly powerful (not saying it does) doesn’t Vue actually do that https://vuejs.org/guide/extras/render-function.html ?
For static sites, this means that you get functions and objects the entire way through the render pipeline right up until there is a full tree built and the final output is rendered.
You still get all the separation powers of contexts, the component based reusability, etc, and it is all regular JavaScript / typescript except for the JSX macro itself and React's APIs (which are just JavaScript). Conversely, with templating engines like handlebars / erb / et al you need to learn the specific DSL of the template engine- custom loops and controls, imports for partials, and your custom helpers are limited to what they can do. Even Vue's render function has special markup for control (v-if, v-else).
PHP intermingled with HTML was bad because developers would do things like run database queries and other operations that caused side effects directly in the markup. Every templating system still has logic in it, and almost every templating system as a way to create custom helpers which are written in the host language.
Since API calls and calls to react's `setState` are asynchronous, and the rendering pipeline is synchronous, it is still obvious that you can't put code that makes an AJAX call in your html markup.
In short, you can do those things maliciously, but if you do them naively it is immediately obvious when you run the code that it's not correct.
Compare that to the original analogy to mixing raw PHP and HTML templates. Since the rendering process is blocking, you can easily stuff form handling, remote API calls, and database calls in amongst your markup, and can make it "work" even if it's not clean.
Even Laravel's blade components let you write custom components and helpers in PHP which can do all of those things from the template- you just don't see the actual SQL mixed with the HTML in the same file. The problem is still there, just now it is harder to see.
Plenty of people were also taught that proper architecture involved an AbstractGetterVisitorFactoryFactory.
That doesn't make either of those things true.
As a side note, if you find yourself wanting a loop but using `map` isn't sufficient, you should probably be preparing the values ahead of time and still using map. It'll be more efficient, and the code easier to read.
But React (like Vue and Svelte) are fundamentally about interactivity. If I had a project where I knew for sure that I only wanted to generate HTML sans JS on the server (or with a static build process) I wouldn't even consider using React.
It barely even makes sense. Your "React components" would just be JavaScript functions that take props and return some JSX. None of the interesting React features and hooks would even make sense, other than maybe context (and presumably most or all popular static HTML templating tools have comparable features).
<%~ includeFile('./navbar', { pages: [
'home',
'about',
'users'
] }) %>
<navbar pages={['home', 'about', 'users']} />
> would just be JavaScript functions that take props and return some JSXThey can also be async functions that process data independently. Whereas templates are commonly just passed in data from the controller.
If you are building a growing design system with any degree of complexity, React is one of the best tools available.
Is that a joke? You get autocomplete from typescript and props to be fully typed functions, or any kind of object for that matter. That compares to autocomplete that's just some ad-hoc, bug ridden tools that locks you into some IDE or editor, and who cares because all the attributes have the same type (string) anyway.
My bash scripts are often edited, I could not imagine using a compiled language where I would have to store the source as a separate file from the executable, then compile it each time.
I'd love to know your more specific use cases, if you don't mind. I'm always happy to learn something new. Could you share some Rust that most people would script in Bash as an example? What's your build and deploy (to ~/.local/bin I presume) strategy?
> What's your build and deploy (to ~/.local/bin I presume) strategy?
You can run scripts as you would with bash, you don't have to manually build and run the executable. For example, `cargo run (inside the script source folder)` and `sh script.sh` do basically the same thing, end user wise. `nim compile --run script.nim` is similar in that the language compiler will automatically compile and run it together.
> Could you share some Rust that most people would script in Bash as an example?
I was creating dotfiles the other day and I didn't want to use some dotfile manager program as I had some specific steps I wanted to follow, so I started it as a bash script. Well, it got kind of annoying so I made it into a Rust script with some nice features like interactive prompts, text coloring, etc with libraries like `clap`. You can do this in bash of course, but the Rust version was more ergonomic. When I need to run the script, I just did `cargo run` and it worked great.
For instance, my most-used bash script takes a file as input and opens either VIM or Emacs depending on whether the file is a .md or .org (simplified example). I run it like so:
$ n foo.org
I can edit ~/.local/bin/n and update the file, and use it immediately. I actually have my whole ~/.local/bin in version control. Having to type out e.g. $ nim compile --run n foo.org
...would make the whole experience far less fluent. I probably would never use it.I'm asking because I'd love to rewrite this script in e.g. Rust, but I don't see any good way to deploy it to ~/.local/bin/n.
eg:
$ code script.nim
#!/usr/bin/env nimcr
echo "hello world"
$ ./script.nim
hello world
edit:There's also the possibility of using nimscript, using nim e. It works similarly but you'd change the shebang line to something like
#!/usr/bin/env nim e --hints:offIn config.nims:
switch("hints", "off")
task hello, "say hello world":
echo "hello world"
In bash: $ nim hello
hello world type ADT =
| { case : 'a', a : Number }
| { case : 'b', b : string }
function f (c : ADT) {
switch(c.case) {
case 'a' : return c.a
case 'b' : return Number.parseInt(c.b)
// case 'c' : return 0 // compile error
// case 'b' : return c.a // also compile error
}
}Specifically I can think of parts of the websites' functionality is editing highly technical structured data documents by highly trained domain experts.
I mean basically where years of developer productivity was thrown down a React hole when it could have been months in SGML / XML based tooling for what was required.
I can say that because I have built big solutions in both stacks, though.
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.
Having that productivity and flexibility without the SPA complexity and other JS cruft has real value.
a. A completely static site with no frontend javascript and no client side hydration, or
b. client hydration in which case all the components needed in the page will need to be loaded in the client.
If you want something in between, ie. only some sections need to be interactive, it requires jumping through some hoops eg. creating separate webpack entrypoints that call ReactDOM.render for specific DOM nodes. It is doable but more work and maintenance effort.
Astro simplifies handling for these kind of islands by using a server side templating language that is component aware and familiar to users already writing jsx.
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.
* 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/
There is also this page comparing it with other tools: https://docs.astro.build/en/comparing-astro-vs-other-tools
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....
It might be overused, that’s an opinion, I don’t agree.
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 :)
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.
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
> 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.
I feel that this is what I was looking for https://docs.astro.build/en/concepts/why-astro/
This gives some more examples of what Astro offers https://twitter.com/matthewcp/status/1557103499724333057?t=8...
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.
I'd like to check it 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-...
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.
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.
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 ;-)
- 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.
> it's literally what we used to do with XMLHttpRequest in IE 5/6 20+ years ago. 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.
That’s not what Astro is doing, or how it’ll mostly be used (though you could do that)
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.
Otherwise called running a business.
I don't mind paying a fair, pre-disclosed price for services that provide value. I do mind opaque enterprise sales tactics that try to take full percentage points off my available runway for no discernable increase in value when I try to add one more user. Doubly so when they go to such lengths to cover it up as Vercel is currently doing.
I recall watching a video on their YouTube account a few months ago where their head of devrel tried to interview a famous personality from the “cloud native” community (Kelsey Hightower) as a way to introduce their “edge functions” nonsense.
The entire thing was a train wreck from about ten minutes in when he started asking questions about how it actually worked and what kind of trade offs it would imply.
I remember they had to do a bunch of obvious hard cuts presumably to remove the more embarrassing stuff and it always stood out as a snake oil company to me ever since then.
The fact that they also seem to rely on deceptive pricing and dark patterns for sales seems very on brand with what I recall thinking about them at the time.
The interview in question is here in case anyone is interested https://youtu.be/yuxd2kurpzk
I cut out parts of the interview to make it shorter. If you’d like to verify what I showed, you can deploy an Astro site with Edge Functions for free: https://vercel.com/templates/astro/astro-edge-functions
Open to feedback on how we can do better next time. Would you prefer more discussion about tradeoffs?
Yeah, because enterprise pricing is so nefarious. It's fine if having to negotiate a contract intimidates you, but there's nothing sinister in it. It's not possible to offer a simple tiered pricing plan that can accommodate every enterprise customer and their usage requirements. Maybe companies A and B have the same number of users, but B consumes 10x the bandwidth. Should B be paying more than A?
Companies can't stay in business if it costs more to service the business than the revenues coming in.
The cover up I was referring to was the 10 user limit before Enterprise pricing gets applied, hidden behind a tooltip deep in their pricing grid.
I thought it was obvious given that every one of these companies have enterprise pricing and advertise it front and center, but only Vercel hides the user limit. Assuming your post is in good faith and not a deliberate strawman, I concede that I could have been more specific.
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.Exactly proving my original point.
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/
Ironically, Composer actually lists npm as one of its inspirations [1].
> "...Composer is strongly inspired by node's npm and ruby's bundler."
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).
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.
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.
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?
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.
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.
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]`
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.
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
You could write your own plugin that calls out to your WASM layer if you want, but I'm not sure we need that built into Caddy. It would be extremely niche, I think.
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.
After spending a little time understanding Go templating it is really beautiful
Instead we spent a week researching how popular 3rd party themes did things, and made a hybrid. Then we moved away completely. I really wanted it to work for us and we were so close. Hugo is so fast and is brilliant on a couple of things.... but barely missed.
I can't remember exactly but with what we were doing we were going to be heavily dependant on their Scratchpad, which felt like a hack. It's all just hacks, and they like it. Lack of solid conventions, and they LOVE it.
My theme is so simple I think redoing it as themeless may be better
It's that theming structure that was a pain to figure out the first time for me
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.
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.
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
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.
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.
If you don't want the trouble, don't chase the new hotness. Use what works until there's a compelling reason to switch.
Use Zola or Hugo. They have zero dependencies.