Skip to content
Happy Programming Guide
Start learning
JavaScript

Introduction to JavaScript Frameworks

What a framework actually does for you, how React, Vue, Svelte and Angular differ, and how to tell whether you need one at all.

A pen and an open notebook ready for notes

A JavaScript framework keeps what is on screen in sync with your data. Without one you write code that finds elements and updates them by hand; with one you describe what the page should look like for a given state, and the framework works out what to change. That is the whole value proposition, and everything else follows from it.

The problem they solve#

Say you have a counter with a number, a progress bar and a message that changes at ten. Without a framework:

JavaScript
let count = 0;

function increment() {
  count++;
  document.querySelector("#count").textContent = count;
  document.querySelector("#bar").style.width = (count * 10) + "%";
  document.querySelector("#message").textContent =
    count >= 10 ? "Done" : "Keep going";
  document.querySelector("#reset").disabled = count === 0;
}

Four manual updates for one change. Add a fifth thing that depends on the count and you must remember to update it here too — and in every other function that changes the count. That is where the bugs come from.

With a framework you describe the relationship once:

JavaScript
function Counter() {
  const [count, setCount] = useState(0);

  return (
    <div>
      <p>{count}</p>
      <div style={{ width: count * 10 + "%" }} />
      <p>{count >= 10 ? "Done" : "Keep going"}</p>
      <button disabled={count === 0}>Reset</button>
      <button onClick={() => setCount(count + 1)}>Add</button>
    </div>
  );
}

Change the count and everything that mentions it updates. You never write an update instruction.

The three shared ideas#

Every framework on this page uses the same three concepts under different names:

  • Components — a reusable piece of interface with its own markup, logic and often styles. A button, a card, a whole page.
  • State — data that belongs to a component and, when it changes, causes a re-render.
  • Props — data passed into a component from its parent, which the component does not change itself.

Learn these once and moving between frameworks is mostly a matter of syntax.

The main options#

Strengths Trade-offs
React largest ecosystem and job market; flexible you assemble routing, forms and state yourself
Vue gentle learning curve; official router and store smaller job market than React
Svelte compiles away, very little runtime; least code smallest ecosystem of the four
Angular everything included; strong conventions steepest start; TypeScript assumed

The same counter in each, so you can see the flavour:

JavaScript
// React
const [count, setCount] = useState(0);
<button onClick={() => setCount(count + 1)}>{count}</button>
HTML
<!-- Vue -->
<script setup>
import { ref } from "vue";
const count = ref(0);
</script>

<template>
  <button @click="count++">{{ count }}</button>
</template>
HTML
<!-- Svelte -->
<script>
  let count = 0;
</script>

<button on:click={() => count++}>{count}</button>

Do you need one?#

Probably not for a blog, a marketing site, a documentation site, a contact form, or a page with a handful of interactive bits. Plain JavaScript is smaller, faster to load and has nothing to keep updated.

Probably yes when several parts of the page depend on the same changing data, when you have real client-side state, when the same interface pieces repeat, or when a team needs shared conventions.

A useful test: count the places you would have to update by hand when one value changes. One or two, and a framework is overhead. Five or more, and it is earning its place.

Learn these first#

Frameworks are built on plain JavaScript, and skipping it makes them much harder, not easier. Be comfortable with:

  • Arrays and objects, especially map, filter and spread
  • Arrow functions and destructuring
  • Modules — import and export
  • Promises, async and await
  • The DOM and events, so you know what the framework is doing for you

The most common cause of frustration with React is not React. It is not being fluent in map and immutable updates.

Starting a project#

Terminal
npm create vite@latest my-app
# choose a framework when prompted

cd my-app
npm install
npm run dev

Vite works for React, Vue and Svelte and starts in seconds. Angular has its own tool:

Terminal
npm install -g @angular/cli
ng new my-app

What comes after the framework#

A framework only handles rendering. Real applications also need:

  • Routing — showing different views for different URLs
  • Data fetching — loading, caching and refreshing server data
  • Forms and validation
  • Shared state across distant components

Vue and Angular provide official answers. React and Svelte leave you to choose, which is why “learning React” often turns into learning four libraries. Meta-frameworks — Next.js, Nuxt, SvelteKit — bundle these decisions together and add server-side rendering, which matters for search visibility.

Questions people ask#

Which should I learn first?

React if you are optimising for job opportunities. Vue or Svelte if you are optimising for a gentle start. The concepts transfer, so the first choice is not permanent.

Is jQuery still relevant?

It solved problems that no longer exist — inconsistent browser APIs and awkward DOM methods. Modern JavaScript covers what it did. Plenty of existing sites use it, so it is worth being able to read.

Do frameworks hurt SEO?

They can, if the page is empty until JavaScript runs. Server-side rendering or static generation, which the meta-frameworks provide, solves it. For a content site, that is a strong argument for one of them.

Should I learn TypeScript at the same time?

Not at first — two new things at once is a lot. Add it once the framework itself feels comfortable. It is close to standard in professional React and Angular work.

Where to go next#

Arrays and objects, the skills every framework assumesRead next

Keep reading

JavaScript

Introduction to ES6 and Beyond

The JavaScript features added since 2015 that changed how the language is written: let and const, arrow functions, destructuring, modules, async/await and…

5 min read

Keep going — pick your next guide

The fastest way to improve is to read one guide, then build the thing it describes. Start with the basics, or jump straight to a project.

Ask a question or share what worked

Your email address will not be published. Required fields are marked *