Hacker News new | ask | show | jobs
by dhucerbin 437 days ago
Value proposition is “components for server”. But it’s worth to take a step back first.

What is value proposition of react component in comparison to older “mvc-inspired” frameworks? That you can drop a component in your code and call it a day. Don’t need to wire up separate controllers, models and views. Just one thing.

Now, if you want to add “auth” to your app (in react meta framework like next) you need to add component and probably add some routes and inject some middleware. With server components, you just add one component somewhere in the root of your app. Just one thing.

All that over the wire format, suspended data fetching etc, are a result of solving that problem and keeping in mind that those components are slightly different. It takes more work, but in return we can interleave both types of components nearly freely.

1 comments

Sorry, having trouble understanding the nuance of the auth example (FYI in react I have experience only in small scale projects). What’s the difference in classic client components having a root component validation auth?
Sure! In some methods of authentication, like OpenID, not only your client need to present some UI, but also you need to prepare some endpoints on the backend to handle full flow of authentication. You probably also need to provide some parameters to those endpoints and methods inside.

So again, you want to add one thing “auth”, but need to add code in multiple places in your app. Server components promise to encapsulate that. Idea is that you can grab a component from npm, and it will handle all of that orchestration for you, and component will be your only one interface, so all configuration can be passed as props (of course it will be taken from your env/secret).

The promise is that you can encapsulate inside a components both client and server code.

Ok I probably need to read deeper into server components and look at specific implementation. Your saying that the same component, in the client makes sure that you have a live session (a la JWT in local storage), but in the backend checks that the client requests arrived with the correct credentials?
Kinda? I’m starting to regret using auth as an example! Dan recommended Sam’s talk to you. He explains that with better examples and more clarity than me.
lol gotcha. Thanks for the time!