Skip to main content

Getting started with TypeScript in React

TypeScript can be used with React.js, just like JavaScript can and is. As TS is a superset of JavaScript, there is, depending on compiler options, no need to actually use TypeScript features. In the following, we'll have a look at unique parts of TSX and how to get started.

TypeScript in create-react-app

There are two ways to get started:

yarn create react-app my-app --template typescript

or:

yarn create react-app my-app --template typescript

TypeScript in Next.js

For Next.js, there are also two ways of getting started:

npx create-next-app@latest --ts

or:

yarn create react-app my-app --template typescript