TypeScript App Host in Aspire
55sReveals a major new feature that lets developers use TypeScript instead of C#, which is highly relevant to a large developer audience.
▶ Play Clip"Delivers exactly what the title promises — a clear demo of using Aspire without C# via TypeScript."
This video demonstrates how .NET Aspire, Microsoft's cloud-native application development framework, now supports TypeScript for defining application hosts, eliminating the need for C#. The presenter shows how to create a distributed application with a Redis cache and a Node.js API using the TypeScript app host, and highlights additional integrations for Go, Bun, and Blazor WebAssembly.
Starting from Aspire 13.4, you can write your app hosts in TypeScript, not just C#.
You create a distributed application builder and add resources with a similar API to the C# app host, e.g., adding a Redis resource as a cache service.
Aspire can host more than .NET applications, including Node applications, by giving a name and pointing to the application files.
You can expose an HTTP endpoint and add a reference to a Redis cache using 'with reference', which injects the connection string at runtime.
Use 'builder.Build and run' to run everything, and the Aspire CLI command 'Aspire run' picks up the TypeScript app host and scaffolds the Aspire dashboard.
The Aspire dashboard shows resources like cache and API, and the resources graph displays how they are connected.
Sending a GET request to the API returns a response and increments a counter in Redis, confirming the connection works.
Aspire now has Go hosting integration, Bun hosting integration, and a preview Blazor WebAssembly hosting integration.
A link is provided in the pinned comment and description for a talk about Aspire from Maddie and David Fowler.
What version of Aspire introduced TypeScript support for app hosts?
Aspire 13.4
00:02
What command do you use to run a TypeScript app host with the Aspire CLI?
Aspire run
00:57
How do you inject a connection string to Redis at runtime in the TypeScript app host?
By calling 'with reference' on the resource.
00:43
Which non-.NET languages or runtimes can Aspire host?
Node.js, Go, Bun, and Blazor WebAssembly (preview).
00:29
What does the Aspire dashboard show?
Resources like cache and API, and a resource graph showing connections.
01:11
TypeScript support
This is a major shift, allowing developers to use Aspire without C#.
00:02Multi-language hosting
Expands Aspire's reach beyond .NET, making it more versatile.
00:29Runtime connection injection
Simplifies configuration by automatically injecting connection strings.
00:43Go and Bun integrations
Shows rapid ecosystem growth and broad language support.
01:58[00:02] for quite a while now, and that's for a very good reason. Starting from Aspire very good reason. Starting from Aspire 13.4, you can write your app hosts in TypeScript. Here's an example of what it looks like. You start by creating your
[00:15] distributed application builder, then you can add your resources with a similar API that you're probably used to from the C# app host. So, we're adding a Redis resource as a cache service. And now, let's also add an API. Now, what's
[00:29] interesting is that we can host more than .NET applications. We can also host Node applications and a few more, but more on that in a moment. So, with the Node integration, you give it a name and point it toward the application files.
[00:43] You can expose an HTTP endpoint, and of course, you can add a reference to a Redis cache by calling with reference. This injects the connection string at runtime. And finally, to run everything with the TypeScript app host, you say
[00:57] builder.Build and run, and all the magic happens under the hood. You can run this using the Aspire CLI, and you type in the command Aspire run, which is going to pick up your TypeScript app host and scaffold the Aspire dashboard, all
[01:11] pretty much identical to the C# experience. You can open up the Aspire dashboard and see your resources there. So, we've got our cache and the API. We can look at the resources graph to see how they're connected, and of course, we
[01:26] can send a request to our Node API. And if we send a get request to the API's response back, and it also has an increment to track how many times we update a counter in Redis, and you can see that with each subsequent request,
[01:42] the counter increases by one, which means that our connection to Redis is working correctly. And remember that we did all of this from the Aspire app host thought that was it, I've got more surprises. Aspire now also has a Go
[01:58] hosting integration and a bun hosting integration, as well as a preview Blazer WebAssembly hosting integration. So, I think it's absolutely amazing how rich the Aspire ecosystem is becoming. And if you want to learn more, I'm going to
[02:12] drop a link in the pinned comment and the description of this video for an awesome talk about Aspire from Maddie and David Fowler. Over to you. Let me know in the comments what you think about the direction that Aspire is going
[02:24] in. And if you've used the Aspire app host with Dapr,
⚡ Saved you 0h 02m reading this? Transcribe any YouTube video for free — no signup needed.