Skip to content

React

I create my React-project in Visual Studio 2022 (at least 17.8.0):

  • React and ASP.NET Core
    A full-stack application with a frontend React project and a backend ASP.NET Core project
    TypeScript Web

Then I can add BFF to the backend.

Laboration

To laborate I will use Visual Studio Code and the “create-react-app” command.

Create a directory/folder for your app. Drag it in to Visual Studio Code. This will open the directory/folder in Visual Studio Code. Now, open the terminal in Visual Studio Code, View -> Terminal and run any of the commands below.

React app with TypeScript:

npx create-react-app ./ --template typescript

React app with JavaScript:

npx create-react-app ./

then

npm start

Common React stuff

Visual Studio React stuff

Examples

Google: react examples

React Router

React Context

Google: react context authentication

API calls

Vite

  1. Go to your project directory. Drag the directory in to Visual Studio Code.
  2. Open the terminal: View -> Terminal
  3. Run command:
npm create vite@latest name-of-your-project -- --template react-ts