How it feels to enter the React Ecosystem in 2024
February 16, 2024
Foreword
Starting a Frontend Project in React this year? Fun times are ahead of you! The following, fictional conversation should help get you into the spirit.
(obviously this is a complete ripoff… ahem, “homage” to: How it feels to learn JavaScript in 2016)
A conversation
Hey, my boss said you’re the guy to talk to about building a state-of-the-art Web app.
Great, thanks! This shouldn’t take long. All I need is to display a list of items from our API on a web page. We’ll also need CRUD: the user should be able to add new items, and edit or delete existing ones.
I thought so! I last touched Frontend 8 years ago. It was dynamic then - new frameworks and libraries every week!
Backbone, Ember, Angular. And React was the cool new kid on the block. I can’t imagine how much better things are now! What do you use in 2024?
Still? Well, I remember React was great because it was so unopinionated, it did only one thing well!
OK, so I’ll just create a new JavaScript project and just include React in there…
I thought React is a framework?
OK, so maybe Create React App?
Ah yes, now I remember Create React App was really hard to customize - it abstracts away the configuration. The frameworks you have now must be really flexible!
So really it’s the same thing…
OK, I’ll just go with this “Vite” Framework I keep hearing about.
What is it?
You said bundling is why I need a framework.
What other stuff?
What’s SSR?
I don’t care about SEO, and performance. It’s a tiny internal app.
Something about the “server” bit in “server-side rendering” bugs me. I thought we were building a frontend app.
But it needs to run on a server?
The kind that’s a single bundle served from a CDN and runs in the browser?
What about if I want to make it Offline-First?
But if I’m “rendering on the server” it sounds like I’ll just be using React as a templating engine? Like EJS in Express?
Hydrate?
Sounds complicated.
And those are?
You mean the server-side rendering you told me about just now?
But React Server Components are different?
But any React Component can fetch data.
You can run the React Dom server API on the server.
So they can execute side effects just like a client-side React component?
useEffect hook?
So “useEffect” is like the “componentDidMount” from back in the day?
But the callback itself is changing the state? Sounds like Infinite Loop City…
OK. Let’s park Infinite Loop City for now. Back to the frameworks: if these “Server Components” don’t have “useEffect” where does the logic go?
export async function ServerComponent() {
const items = await getItems()
return(
<>
{items.map((i, index) => {
<Item key={index} data={i} />
})}
</>
)
}
Just some async logic right in the component body? And how does this run on the client?
So what runs on the client?
So React, the unopitionated Frontend Library now has a special designation for code that’s supposed to run in the browser?
What do you mean “not in a single file”? Never mind. Anything else I should know about using Server Component.
Which ones support it?
That’s like 5 libraries. What about the rest of them?
And every one of the frameworks, one of which I absolutely need to use, runs on this Server Component paradigm?
Oh. So I could just pick a different framework?
What’s Vercel?
But NextJS is open-source?
And I can deploy the app I developed with their framework on their hosting service?
But I don’t have to? I could host it somewhere else too? Cloudflare Pages, Netlify? It’s just a NodeJS app at the end of the day, right?
Maybe I’ll use that instead?
Will Netlify run NextJS or not?
What about Cloudflare Pages?
The Microsoft browser?
Who came up with this Edge Runtime?
Right. Anyway so I just put
{runtime: 'experimental-edge'}
somewhere in the settings and I can deploy on Cloudflare Pages?
Stop saying “be smart”. Also, “simple” is not a word I would use to describe any of this.
You sure seem to be pushing Vercel a lot.
…and seems like they (Vercel) recently picked up $300 million in Venture Capital funding to “drive adoption”…
OK. I think I’m done here. I’ll go build this in ASP .Net and host it in Azure. At least I know what I’m getting into.