You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which scope/s are relevant/related to the feature request?
create-analog
Information
Hear me out. This would be amazing. Imagine creating the DOM on the server and rendering the HTML for non-interactive components. I doubt Angular will every go in this direction unless Solid and Svelte get on board one day (no idea). It would simplify hydration (you wouldn't need it), and make things beautiful.
I would think you start with just routes (think something like component.server.analog. Basically having a .server in the name makes it a server component. Later you could add client components inside the server component maybe.
This could be easier than it sounds if the complexity is not crazy.
Describe any alternatives/workarounds you're currently using
Not the same thing. What Angular is missing and has always been missing (and seemingly will always be missing) is server only code.
I want to generate the html safely on the server, fetch from a database with private credentials, all in one component, and seemingly have child client components that can be reactive.
Oh yeah, your right. That's only true for the initial navigation rendered by the server. In that case the code won't ship to the browser. And it also says, that it cannot have interactive child components.
What do you think are the benefits of using a server component compared to using a never hydrated component connected to a server function? My thoughts are:
Being able to ship static html on subsequent navigations
having interactive islands inside a static component
Yes, not every component needs to be hydrated, so this is important. But the benefit of (A)SC would be ability to run server safe code inside the component safely and only hydrate reactive JS, not shipping unnecessary code to the browser. This increases speed, gives better SEO (core web vitals), is safer, and cleaner code.
Yea, that's the target with this feature. Ideally, it would work alongside incremental hydration, but all the rendered content is done server-side, even with support for props. I have a prototype working already
Activity
[-]Server Components[/-][+]Feature: Server Only Components[/+]tobiasegli commentedon Nov 24, 2024
@jdgamble555, with Angular v19 this feature just got released (in preview) as part of incremental hydration.
https://angular.dev/guide/incremental-hydration#hydrate-never
jdgamble555 commentedon Nov 24, 2024
Not the same thing. What Angular is missing and has always been missing (and seemingly will always be missing) is server only code.
I want to generate the html safely on the server, fetch from a database with private credentials, all in one component, and seemingly have child client components that can be reactive.
This is what RSC can do.
Unless I'm missing something.
J
tobiasegli commentedon Nov 24, 2024
Oh yeah, your right. That's only true for the initial navigation rendered by the server. In that case the code won't ship to the browser. And it also says, that it cannot have interactive child components.
What do you think are the benefits of using a server component compared to using a never hydrated component connected to a server function? My thoughts are:
jdgamble555 commentedon Nov 24, 2024
Yes, not every component needs to be hydrated, so this is important. But the benefit of (A)SC would be ability to run server safe code inside the component safely and only hydrate reactive JS, not shipping unnecessary code to the browser. This increases speed, gives better SEO (core web vitals), is safer, and cleaner code.
J
brandonroberts commentedon Nov 25, 2024
Yea, that's the target with this feature. Ideally, it would work alongside incremental hydration, but all the rendered content is done server-side, even with support for props. I have a prototype working already
jdgamble555 commentedon Nov 26, 2024
Could you run server safe code? (ex fetch from db with credentials hidden from client)
brandonroberts commentedon Nov 26, 2024
Yes, the component is only rendered server-side, with its HTML and "outputs" returned.