npx create-react-app myproj --template typescript
npx create-react-app myproj --template typescript
Download the create-react-app package from npm and execute it with parameter template equals to typescript
/public
index.html // root file to load
manifest.json // web app metadata
/src
App.css // styles related to the App component
App.test.tsx // tests related to the App component
App.tsx // App component
index.css // Global styles
react-app-env.d.ts // extra types
reportWebVitals.ts // performance metrics report
setupTests.ts // test configuration
.gitignore // git ignore configuration
package-lock.json // all project dependencies
package.json // project configuration file
tsconfig.json // typescript configuration file
Start application for local development
npm start
Tests application
npm test
Builds application for production - bundling, minification, etc
npm run build
Converts create-react-app to the regular front-end app
npm run eject
⚠️ It's one time action
import "./App.css";
function App() {
return (
<div className="App">
hello world
</div>;
);
}
export default App;
import "./App.css";
function App() {
return (
<div className="App">
hello world
</div>;
);
}
export default App;
Feel free to alter the code inside the div. You can add any other HTML tag you know or text. However, tags are not HTML - it's TSX
After saving the file React will update the UI automatically. This called Hot Module Reloading
import "./App.css";
const data = { greetings: "Hello World!" };
function App() {
return ({data.greetings});
}
export default App;
npm init vite