aspnetcore/release-notes/aspnetcore-9/includes/signalr-trimming-aot.md
Continuing the Native AOT journey started in .NET 8, we have enabled trimming and native ahead-of-time (AOT) compilation support for both SignalR client and server scenarios. You can now take advantage of the performance benefits of using Native AOT in applications that use SignalR for real-time web communications.
Install the latest .NET 9 SDK.
Create a solution from the webapiaot template in a command shell using the following command:
dotnet new webapiaot -o SignalRChatAOTExample
Replace the contents of the Program.cs file with the following SignalR code:
The preceding example produces a native Windows executable of 10 MB and a Linux executable of 10.9 MB.
System.Text.Json Source Generator.IAsyncEnumerable<T> and ChannelReader<T> where T is a ValueType (struct) aren't supported. Using these types results in a runtime exception at startup in development and in the published app. For more information, see SignalR: Using IAsyncEnumerable<T> and ChannelReader<T> with ValueTypes in native AOT (dotnet/aspnetcore #56179).PublishAot). Using strongly typed hubs with Native AOT will result in warnings during build and publish, and a runtime exception. Using strongly typed hubs with trimming (PublishedTrimmed) is supported.Task, Task<T>, ValueTask, or ValueTask<T> are supported for async return types.