Skip to content

Commit 77a4011

Browse files
JeanMechemmalerba
authored andcommitted
docs: add providers caveat on the service (angular#64269)
fixes angular#60955 PR Close angular#64269
1 parent 69b3c05 commit 77a4011

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

adev/src/content/guide/ssr.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,13 @@ export class MyComponent {
267267
}
268268
```
269269

270+
## Setting providers on the server
271+
272+
On the server side, top level provider values are set once when the application code is initially parsed and evaluated.
273+
This means that providers configured with `useValue` will keep their value across multiple requests, until the server application is restarted.
274+
275+
If you want to generate a new value for each request, use a factory provider with `useFactory`. The factory function will run for every incoming request, ensuring that a new value is created and assigned to the token each time.
276+
270277
## Accessing Request and Response via DI
271278

272279
The `@angular/core` package provides several tokens for interacting with the server-side rendering environment. These tokens give you access to crucial information and objects within your Angular application during SSR.

0 commit comments

Comments
 (0)