init to prod

Sam Kamperis

Thursday, October 1, 2026

Introduction

Dr Sam Kamperis FIMA MBCS

Senior Lecturer at Oxford Brookes University.

Organiser of the Year 12 Masterclasses in Oxfordshire.

I’m a mathematician, I teach on the courses in Mathematics, Data Analytics and Computer Science.

PhD in Algorithmic Graph Theory

I make computers draw triangles.

The workshop

Ten weeks, starting tomorrow: Thursday 8 October

  • Weekly sessions: Thursdays, 12:00-14:00
  • In person: NHHB1.13
  • One-hour online webinar early next week; time and joining details to follow

Outcomes

  • Build a simple counter in HTML with vanilla JS, React and Svelte
  • Understand how state and reactivity work for the counter in the three frameworks
  • Explain how Svelte 5 runes make values reactive

Vanilla JavaScript: update the DOM

<button id="counter">Clicked 0 times</button>
<script>
  let count = 0;
  const button = document.querySelector('#counter');

  button.addEventListener('click', () => {
    count += 1;
    button.textContent = `Clicked ${count} ${count === 1 ? 'time' : 'times'}`;
  });
</script>

The event handler updates both the JavaScript value and the button text.

React: state triggers a render

import { useState } from 'react';

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

  return (
    <button onClick={() => setCount((current) => current + 1)}>
      Clicked {count} {count === 1 ? 'time' : 'times'}
    </button>
  );
}

Call the state setter to update the value; React renders the button again.

Svelte: state updates the view

<script>
  let count = $state(0);

  function increment() {
    count += 1;
  }
</script>

<button onclick={increment}>
  Clicked {count} {count === 1 ? 'time' : 'times'}
</button>

$state marks count as reactive, so changing it updates the button.

Svelte 5: reactivity with runes

Runes are special functions understood by the Svelte compiler. They tell Svelte how values participate in reactivity.

  • $state makes a value reactive
  • $derived calculates a value from state
  • $effect synchronizes state with an external system

$derived: calculate from state

The derived value stays in sync as count changes.

<script>
  let count = $state(0);
  let isEven = $derived(count % 2 === 0);
</script>

<p>{isEven ? 'Even' : 'Odd'}</p>

$effect: synchronize with the outside world

Use an effect for an external system, such as the browser tab title. Prefer $derived for values calculated from state.

<script>
  let count = $state(0);

  $effect(() => {
    document.title = `Count: ${count}`;
  });
</script>

Compare the mental models

  • Vanilla JavaScript: update the value and the DOM yourself.
  • React: update state with a setter; React renders again.
  • Svelte: update reactive state; the compiler updates the view.

In all three, the counter is state. The frameworks differ in how changes reach the page.

Thank you! Any questions?