Skip to content

Feature: Server Only Components #989

Closed

Description

@jdgamble555

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

I would be willing to submit a PR to fix this issue

  • Yes
  • No

Activity

  1. added
    enhancement
    on Mar 31, 2024
  2. changed the title [-]Server Components[/-] [+]Feature: Server Only Components[/+] on Aug 30, 2024
  3. tobiasegli commented on Nov 24, 2024

    @tobiasegli
    Contributor

    @jdgamble555, with Angular v19 this feature just got released (in preview) as part of incremental hydration.
    https://angular.dev/guide/incremental-hydration#hydrate-never

  4. jdgamble555 commented on Nov 24, 2024

    @jdgamble555
    Author

    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

  5. tobiasegli commented on Nov 24, 2024

    @tobiasegli
    Contributor

    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
  6. jdgamble555 commented on Nov 24, 2024

    @jdgamble555
    Author

    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

  7. brandonroberts commented on Nov 25, 2024

    @brandonroberts
    Member

    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

  8. jdgamble555 commented on Nov 26, 2024

    @jdgamble555
    Author

    Could you run server safe code? (ex fetch from db with credentials hidden from client)

  9. brandonroberts commented on Nov 26, 2024

    @brandonroberts
    Member

    Yes, the component is only rendered server-side, with its HTML and "outputs" returned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions