Skip to content

Expose SERVER_CONTEXT InjectionToken in public API #64884

@vz-tl

Description

@vz-tl

Which @angular/* package(s) are relevant/related to the feature request?

platform-server

Description

When utilizing renderApplication() directly for e.g. implementing a custom SSR app render engine, it's not possible to apply the correct server-context like "ssr", as this requires to add the private SERVER_CONTEXT InjectionToken to platformProviders. The only way to apply the right context is to import the token in a hacky way by ignoring the export being prefixed with ɵ, marking it as private / not part of the public API.

The token was introduced in 2022 with this PR: #47103

As stated in this PR comment it sounds like a future exposure has already been considered:

We can make it fully public later once we test everything end-to-end and collect the feedback.

The above change was merged already 3 years ago, so it should now be safe to expose the token. It might be needed to also expose an Enum holding the possible values (similar to RenderMode but with the correct string representations instead of numeric values).

Proposed solution

Expose SERVER_CONTEXT InjectionToken in public API

Alternatives considered

none

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: serverIssues related to server-side renderingneeds: clarificationThis issue needs additional clarification from the reporter before the team can investigate.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions