Skip to content

Commit 9a50e78

Browse files
committed
docs: refresh readme for Angular 20
1 parent 2e80a23 commit 9a50e78

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

README.md

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ Netlify automatically detects Angular projects and sets up the latest version of
3333

3434
There's no further configuration needed from Netlify users.
3535

36-
### For Angular 19
36+
### For Angular 19 and Angular 20
3737

3838
If you are using Server-Side Rendering you will need to install Angular Runtime in your Angular project to be able to import required utilities to successfully deploy request handler to Netlify. See [Manual Installation](#manual-installation) for installations details. See [Request handling](#request-handling) for more information about request handler.
3939

4040
### Manual Installation
4141

42-
If you need to pin this plugin to a specific version or if you are using Server-Side Rendering with Angular 19, you will need to install the plugin manually.
42+
If you need to pin this plugin to a specific version or if you are using Server-Side Rendering with Angular 19 or Angular 20, you will need to install the plugin manually.
4343

4444
Install it via your package manager:
4545

@@ -77,9 +77,10 @@ To test this in local development, run your Angular project using `netlify serve
7777
```sh
7878
netlify serve
7979
```
80-
### App Engine Developer Preview usage with Angular@19
8180

82-
If you opt into the App Engine Developer Preview accessing `Request` and `Context` objects is streamlined. Instead of custom Netlify prefixed providers, you should use the standardized injection tokens for those provided by `@angular/core` instead:
81+
### App Engine usage
82+
83+
With App Engine accessing `Request` and `Context` objects is streamlined. Instead of custom Netlify prefixed providers, you should use the standardized injection tokens for those provided by `@angular/core` instead:
8384

8485
```diff
8586
+import { REQUEST, REQUEST_CONTEXT } from '@angular/core'
@@ -101,6 +102,8 @@ export class FooComponent {
101102
}
102103
```
103104

105+
Note that App Engine in Angular 19 is in Developer Preview and requires explicit opt-in.
106+
104107
## Request handling
105108

106109
Starting with Angular@19. The build plugin makes use of the `server.ts` file to handle requests. The default Angular scaffolding generates incompatible code for Netlify so the build plugin will swap it for compatible `server.ts` file automatically if it detects default version being used.
@@ -111,52 +114,52 @@ Make sure you have `@netlify/angular-runtime` version 2.2.0 or later installed i
111114

112115
If you need to customize the request handling, you can do so by copying one of code snippets below to your `server.ts` file.
113116

114-
If you did not opt into the App Engine Developer Preview:
117+
If you are using Angular 20 or Angular 19 with App Engine Developer Preview:
115118

116119
```ts
117-
import { CommonEngine } from '@angular/ssr/node'
118-
import { render } from '@netlify/angular-runtime/common-engine.mjs'
120+
import { AngularAppEngine, createRequestHandler } from '@angular/ssr'
121+
import { getContext } from '@netlify/angular-runtime/context.mjs'
119122

120-
const commonEngine = new CommonEngine()
123+
const angularAppEngine = new AngularAppEngine()
124+
125+
export async function netlifyAppEngineHandler(request: Request): Promise<Response> {
126+
const context = getContext()
121127

122-
export async function netlifyCommonEngineHandler(request: Request, context: any): Promise<Response> {
123128
// Example API endpoints can be defined here.
124129
// Uncomment and define endpoints as necessary.
125130
// const pathname = new URL(request.url).pathname;
126131
// if (pathname === '/api/hello') {
127132
// return Response.json({ message: 'Hello from the API' });
128133
// }
129134

130-
return await render(commonEngine)
135+
const result = await angularAppEngine.handle(request, context)
136+
return result || new Response('Not found', { status: 404 })
131137
}
138+
139+
/**
140+
* The request handler used by the Angular CLI (dev-server and during build).
141+
*/
142+
export const reqHandler = createRequestHandler(netlifyAppEngineHandler)
132143
```
133144

134-
If you opted into the App Engine Developer Preview:
145+
If you are using Angular 19 and did not opt into the App Engine Developer Preview:
135146

136147
```ts
137-
import { AngularAppEngine, createRequestHandler } from '@angular/ssr'
138-
import { getContext } from '@netlify/angular-runtime/context.mjs'
139-
140-
const angularAppEngine = new AngularAppEngine()
148+
import { CommonEngine } from '@angular/ssr/node'
149+
import { render } from '@netlify/angular-runtime/common-engine.mjs'
141150

142-
export async function netlifyAppEngineHandler(request: Request): Promise<Response> {
143-
const context = getContext()
151+
const commonEngine = new CommonEngine()
144152

153+
export async function netlifyCommonEngineHandler(request: Request, context: any): Promise<Response> {
145154
// Example API endpoints can be defined here.
146155
// Uncomment and define endpoints as necessary.
147156
// const pathname = new URL(request.url).pathname;
148157
// if (pathname === '/api/hello') {
149158
// return Response.json({ message: 'Hello from the API' });
150159
// }
151160

152-
const result = await angularAppEngine.handle(request, context)
153-
return result || new Response('Not found', { status: 404 })
161+
return await render(commonEngine)
154162
}
155-
156-
/**
157-
* The request handler used by the Angular CLI (dev-server and during build).
158-
*/
159-
export const reqHandler = createRequestHandler(netlifyAppEngineHandler)
160163
```
161164

162165
### Limitations

0 commit comments

Comments
 (0)