Home
17 comments
turtlebits16 days ago
I dont get it. Yes it's a static site, but it's only text and you're sending 100kb+ of JS over the wire. Is there any reason why you need React?
评论 #43932872 未加载
评论 #43945117 未加载
评论 #43933862 未加载
评论 #43933587 未加载
评论 #43933152 未加载
girvo16 days ago
> This builds on an insight that seems obvious in retrospect: you can take any “server” framework and get a “static” site out of it by running its “server” during the build and hitting it with a request for every page you want to generate, and then storing the responses on disk<p>I'm showing my age, but we used to do this using Wordpress <i>ages</i> ago. Like 15 years ago or more haha.
评论 #43934565 未加载
评论 #43934098 未加载
评论 #43945155 未加载
KronisLV15 days ago
> First, the “hybrid” approach reduces tooling fragmentation—why have two ecosystems when the overlap is so large? The difference is just when the code runs.<p>Because you end up with two subsets of supported features in the same technology, even in the linked page: <a href="https://nextjs.org/docs/pages/guides/static-exports" rel="nofollow">https://nextjs.org/docs/pages/guides/static-exports</a><p><pre><code> Supported Features
The majority of core Next.js features needed to build a static site are supported, including:
Dynamic Routes when using getStaticPaths
Prefetching with next/link
Preloading JavaScript
Dynamic Imports
Any styling options (e.g. CSS Modules, styled-jsx)
Client-side data fetching
getStaticProps
getStaticPaths
Unsupported Features
Features that require a Node.js server, or dynamic logic that cannot be computed during the build process, are not supported:
Internationalized Routing
API Routes
Rewrites
Redirects
Headers
Middleware
Incremental Static Regeneration
Image Optimization with the default loader
Draft Mode
getStaticPaths with fallback: true
getStaticPaths with fallback: 'blocking'
getServerSideProps
</code></pre>
To me, this feels about as awkward as React moving from class based components to function and hook based ones, dragging a lot of the large libraries alongside with it, meaning that if you tried using class based ones for a while you'd run into cases where some of your dependencies would only offer documentation for the functional approach.<p>Mixing approaches that differ so much inevitably leads to awkwardness. I'd prefer a SPA library/framework without awkward sharp edges and a separate SSR solution, each specialized at what they do, neither trying to do everything. That way the toolchains remain simpler, there's fewer abstractions at play and fewer things to keep in mind. But if one tool to rule them all works for you, then great!
评论 #43936589 未加载
评论 #43935773 未加载
zeropointsh16 days ago
My exact thoughts[1] when it comes to hosting, things should be static, although I seek joy in Astro and Markdown.
[1]<a href="https://zeropoint.sh/blog/astro-as-static/" rel="nofollow">https://zeropoint.sh/blog/astro-as-static/</a>
评论 #43933198 未加载
评论 #43934426 未加载
exogen16 days ago
This is also how I build most of my static sites, usually deployed to GitHub Pages. For example, here’s the demo page for a library I recently developed: <a href="https://exogen.github.io/turbo-colormap/" rel="nofollow">https://exogen.github.io/turbo-colormap/</a><p>Or a more complicated app: <a href="https://exogen.github.io/t2-model-skinner/" rel="nofollow">https://exogen.github.io/t2-model-skinner/</a><p>Are all of Next.js’ features overkill for such sites? Sure, but the convenience such frameworks provide is worth it. And the reason to prefer it over something like Vite is simply routing, which Vite doesn’t cover out of the box, so as soon as I want to add a second page, I now have another problem to solve.<p>Next.js’ best feature is simply that you’re up and running with `npm i react react-dom next` and step two is just writing the pages.
atoko16 days ago
I wonder if the omission of React Context in this example is intentional. Do you think Context is compatible with suspense? In the sense that posts is being passed to components as props three times over.<p>Is it because each component is expected to abstract over async, relying on the promise state?
评论 #43930579 未加载
raddan16 days ago
I understand that somebody might want to generate static pages from code that generates it dynamically, but I fail to appreciate _why_. Are people using this for a handful of pages they want to load quickly and whose contents rarely change, or are people building entire static sites using things like React? If it's the latter... uh... why? It's been awhile since I was a web developer, so maybe my pain threshold is inappropriately low. I think Jekyll is fine and use it pretty regularly.
评论 #43930442 未加载
评论 #43930675 未加载
评论 #43930488 未加载
评论 #43930518 未加载
评论 #43931550 未加载
评论 #43930497 未加载
评论 #43932324 未加载
评论 #43932427 未加载
评论 #43931507 未加载
评论 #43931586 未加载
评论 #43950140 未加载
评论 #43930362 未加载
owebmaster11 days ago
You guys gotta understand that Next.js is killing React. Just read reddit and HN, nobody asked for those features - we know it is being pushed just to make money, but a library/framework should not be guided by VC objectives.
throwaway31415516 days ago
I am having trouble understanding this article's premise:<p>```<p>RSC means React Server Components.<p>And yet, although this blog is built with RSC, it is statically served from a Cloudflare CDN using their free static hosting plan. It costs me exactly zero.<p>Zero.<p>How is this possible?<p>Aren’t these React Server Components?<p>```<p>Why is any of that confusing? The very first thing I think of when someone says "React Server Components" is, well, server side rendering of react components. What else could it possibly be? Is anyone who is an established React developer really confused by this?
评论 #43931115 未加载
评论 #43931003 未加载
_benton16 days ago
I'm curious if Next has full support for Cloudflare or if this is the only way to run Next w/RSC off of Vercel.
评论 #43932895 未加载
ktpsns16 days ago
This got popular in JS toolkits a few years ago, at least. For instance, Svelte(kit) also has a static output variant.
revskill16 days ago
If you put a cache around all GET API handler, you're faster than static.
评论 #43930728 未加载
评论 #43930601 未加载
switz16 days ago
It's unfortunate that there is so much misinformation about what react server components really are, but it's not necessarily the fault of either party. The name is confusing (names are hard), the architecture is new (people don't want to learn it), and it lends itself to conspiracy theories (that aren't true).<p>But it really is a magnificent piece of technology. Because they're called "Server Components" people think that "server" means run-time, but as a friend pointed out, 15 years ago people were running wordpress servers and caching pages ahead-of-time. As Dan mentions here: "server" doesn't imply it has to execute at run-time.<p>But there are also massive advantages to running a server at run-time that seem lost on people. I do think over time the concepts behind RSCs will filter out into most web frameworks because they are so powerful. It's the best functionality of the old-world SSR languages (PHP, rails) combined with the best functionality of the new-world client frameworks (React). You get to pick and choose when to lean on either, and they work together through composition.<p>I wish people were a bit more patient and spent a bit more time trying to understand these concepts before bashing them. Part of that is the fault of names, communication, and lack of documentation. But the underlying technology is rigid and strong. It's here to stay, even if it arrives in other forms.
评论 #43929949 未加载
评论 #43930445 未加载
评论 #43931610 未加载
评论 #43930423 未加载
评论 #43939389 未加载
joshcsimmons15 days ago
React is a technique not a technology.
exiguus16 days ago
Basically this started with vercel / next.js. And now react support server components itself.
Its nice, if you have business requirements that you can't handle with the classic JAMStack approach. For example a shop, where the stock of products updates the UI (e.g. there is a sold-out label and the add to cart button should be disabled if out of stock).
Lets say we use next.
After a code update or with a cron job, you build the site every 6h. 3k pages (every product, categories etc.). Then, you use server componts and ISR with a ttl of 10min. ISR 10min means, the page get rebuild on the server after 10min with the next request and button gets disabled if the product is out of stock.<p>Yes, you don't need this, and you can directly call an API, but, thats bad for the user, because they have to wait for the API request (and UI update) and bad for you, because you have as many API request, you have as page visits.<p>So, server components bring value with the ttl / revalidate option of the page.
A framework like next/vercel brings value if you want to maintain you page over the next 10 years with more then 1 developer.