'Creating a (.NET 6 based) website project with ASP.NET Core and React (TypeScript) in Visual Studio 2022?

I have been trying to set up an ASP.NET Core + React (TypeScript) web app project in Visual Studio 2022, but couldn't succeed in doing so. There are no proper stacks/suites(?) in the Visual Studio 2022 create project dialog (File > New > Project...) that suit my needs.

I then tried what these docs say - and it works - but when I do the same for React TypeScript (i.e., using Standalone TypeScript React Template instead of Standalone JavaScript React Template) it doesn't work because this template doesn't have an Add integration for Empty ASP.NET Web API project. option in its setup (but the JavaScript template does).

How do I create an ASP.NET Core + React (TypeScript) project then?

I did see some modified and new files when the ASP.NET Core Web API integration option was enabled during the React.js (not TypeScript) setup. Can I copy those ASP.NET Core Web API integration files and their content, re-write the JavaScript files in TypeScript, and add those files (*.ts instead of *.js, etc.) in the TypeScript template? Or is there any other (official) method to properly set up an ASP.NET Core + React (TypeScript) project in Visual Studio 2022?



Solution 1:[1]

This is the guide do you need, just a consideration I changed this piece of code in aspnetcore-react.ts

fs.writeFileSync(
    '.env.development.local',
    `BROWSER=none
    HTTPS=true
    SSL_CRT_FILE=${certFilePath}
    SSL_KEY_FILE=${keyFilePath}`,
);

BROWSER=none Start without opening url in the browser because should be opened by .NET proxy

HTTPS=true Dev server to serve pages over HTTPS. Uses the .NET self-signed certificate

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Juan Calderon