React Get Started

Create a React project with Vite.

✍️ 3 exercises + code challenge in this lesson

For real projects, create an app with a build tool. The recommended starting point is Vite:

  1. Install Node.js (see the Node.js tutorial).
  2. npm create vite@latest my-app -- --template react
  3. cd my-app, then npm install
  4. npm run dev and open the URL it prints.

Your code lives in src/; main.jsx mounts the root App component. Frameworks like Next.js add routing and server rendering on top of React.

The examples here load React from a CDN with Babel, so they run directly in the browser editor.

Key Takeaways: React Get Started

Mastering React Get Started helps you write clean and reliable React code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.

React Get Started Code Example

React
<div id="root"></div>
<script src="https://unpkg.com/react@18.3.1/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@18.3.1/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/@babel/standalone@7.25.6/babel.min.js"></script>

<script type="text/babel">
const { useState, useEffect, useRef, useMemo, createContext, useContext } = React;
function App() {
  return (
    <div style={{ fontFamily: "sans-serif" }}>
      <h2>My first React app</h2>
      <p>Edit this component and press Run.</p>
    </div>
  );
}

ReactDOM.createRoot(document.getElementById("root")).render(<App />);
</script>
Free sign-in required · Google login available

React Get Started Practice Exercises

Check what you learned in “React Get Started”.

/ 3 solved
Fill in the blank

Create a new React app with Vite.

npm create @latest my-app -- --template react
✓ Correct! Not quite. Try again.
Multiple choice

Which command starts the Vite development server?

✓ Correct! Not quite. Try again.
Code challenge

Render a <p> with the text "My first app".

Write the code in the live editor. Your answer is checked automatically.

Free sign-in required · Google login available

to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services