RSC for Astro Developers
23 comments
·May 6, 2025skeptrune
danabramov
I slightly disagree with your nit. I don’t think code fence really demarcates the boundary because the code below the fence definitely does run on the server — otherwise, referencing other Astro components wouldn’t work there. The fence represents the “bindings vs template” separation but not “server vs client” in my reading.
skeptrune
Fair point, you've convinced me on the "bindings vs template" distinction.
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.
danabramov
Yeah. Not saying it’s the same thing but the conceptual equivalent to this boundary is
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).
pier25
> share context between islands
This is extremely easy to solve with Astro:
skeptrune
>In Astro, you can nest Astro Components inside Client Islands, but if those include more Client Islands, they’ll still be seen as separate roots by your framework (e.g. React). This is why nesting interactive behavior doesn’t compose as naturally as in client apps, e.g. React or Vue context can’t be passed between Astro islands.
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.
pier25
You're right. Sorry I misunderstood. For some reason instead of "context" I read "state".
brudgers
Astro is The web framework for content-driven websites.
insin
Former Gatsby users know where they were on the day they freed themselves from that flaky image processing pipeline piped through GraphQL (they were at their computer).
There's no evidence for this, but it's a scientific fact that Astro has five 9s... in its net promoter score.
swyx
fellow gatsby refugee here but i'd be fair to gatsby that i dont think the flakiness of the image processing is gatsby's fault, it's `sharp`, its just a very cpu heavy workload and for large sites it's gonna choke. graphql had nothing to do with this one
pier25
Astro is great.
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
If you're planning on using any framework (like React), I won't recommend it. The reason being, if you're using any library from React which depends on the Context API, it will cause issues since you'll have to wrap your respective pages/components with it and handle navigation on the client side to preserve any global "state" if any. At which point, you're better off using a fullstack framework.
betterThanTexas
> The web framework for content-driven websites.
As opposed to those driven by, what, random-number generators?
naet
There are "content" driven websites which are things like blogs, marketing / brochure style sites, documentation sites, etc. They are driven by content that is authored by the website owners that can then be cached or is not frequently updated by end users or external data.
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".
ameliaquining
I think this means, as opposed to rich interactive web apps where everything interesting happens after the initial page load.
betterThanTexas
I have no clue how you discerned this from the description, but I'd like to understand more. What can you point to on your computer that isn't "content"?
flashblaze
Love love love Astro. Been using it since it was launched. My personal site and 1st product's landing page both are built using Astro. Builds fast, has the ability to ship 0 JS and allows to any frontend libarary makes it a killer framework imo.
animanoir
[dead]
Only reason why I would use RSC's over Astro is to share context between islands. There's no other major benefit.
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'.