Also, nit, but I wish this article explicitly mentioned and explained Astro's "code fence" idea. It's demarcates the boundary between server and client much more clearly than React's 'use client'.
This is extremely easy to solve with Astro:
I agree with what the link author wrote here. Nanostores is great (s/o EvilMartians), but it's not as natural or easy to use as each respective framework's context solution.
However, from a developer's perspective, the ability to securely make backend requests with secrets in the top fenced area and pass results to the template still feels like a clear "server-side execution context" boundary.
import "server-only"
This causes a build error if imported from a client environment. So the intended usage is that you put that into your secrets (and maybe even in your data layer entry point) and you’re golden. It will poison any transitive import that eventually imports that thing.
The developer wouldn’t necessarily “see” where they are at any given moment but importing the “wrong thing” would give them a module stack trace so they can decide where to “make the cut”. It takes a bit to embrace this workflow but it’s productive once you “mark” what’s server-only.
The enforcement of “can’t use state on the client” is built on the same mechanism but inverse (client-only).
brudgers•3d ago
https://github.com/withastro/astro
betterThanTexas•3d ago
As opposed to those driven by, what, random-number generators?
ameliaquining•3d ago
betterThanTexas•3d ago
pcthrowaway•3d ago
For example, a Javascript+HTML game might be itself considered content, but within the game the game elements and controls (mouse, player characters, NPCs, keyboard bindings) wouldn't be considered content, whereas images and dialog text might reasonably considered content again.
betterThanTexas•3d ago
it almost seems like the word "content" is intended to connote "profitable and dynamically-loaded assets". Why you would not use that phrase is a mystery.
I suppose that "dynamically-loadable asset creator" isn't a great marketing pitch from the perspective of artists.
azangru•3d ago
One way of understanding the meaning of a dubious phrase is examining its use in context. For example, one of the pages of the Astro docs begins as follows:
"Astro is the web framework for building content-driven websites like blogs, marketing, and e-commerce" [0]
Ok; so we have our prototypes — or, as Jason Miller would call them, holotypes — of the mysterious "content-driven websites". They are blogs, marketing sites, or e-commerce sites.
Another way of understanding the meaning of a confusing phrase is hearing the distinction explained by the creator of the framework. In early podcasts, when Astro was still mostly unknown, Fred Schott explained that it was not intended for building something like Figma, or Photoshop, or Facebook, or Youtube; but rather something like blogs or magazines; although primarily he was probably targeting the creators of e-commerce websites, because those were the ones that could bring in money.
[0] https://docs.astro.build/en/concepts/why-astro/
betterThanTexas•3d ago
Ok, but opposed to what? What does a non-content oriented website look like? Is a website itself not simply content?
> Fred Schott explained that it was not intended for building something like Figma, or Photoshop, or Facebook, or Youtube
Perhaps their tagline should be "we aren't oriented around building single page websites unlike all those other frameworks". I never would have understood that Figma, Photoshop, and Youtube were not content-oriented websites otherwise. "Content" is mostly not a meaningful phrase outside of a context which gives it meaning (i.e. it is a floating signifier).
azangru•3d ago
naet•3d ago
Then there are sites that are more application driven or service driven. Stuff like a messaging client, social media, streaming service, eCommerce, or other full on interactive web app. They tend to be more data driven or dependent on end users, and less static content.
That is frequently how the word content is used in the context of web development. You might have heard of a CMS or content management system. It's not the same as someone using the word content like social media "content creator".
insin•3d ago
There's no evidence for this, but it's a scientific fact that Astro has five 9s... in its net promoter score.
swyx•3d ago
pier25•3d ago
It became my default SSG a couple of years ago and now I'm seriously considering using it for apps too. Anyone has experience with that?
I'm thinking I could just use Astro for rendering the HTML with islands but still use a non-JS backend.
flashblaze•2d ago