Popular Lesson

3.2 – Build a Backend Server with an API Lesson

In this lesson, you’ll shift focus from your app’s front end to set up your first backend server. You’ll use Cloudflare Workers to create an API so your UI can reliably communicate with your backend. The core walkthrough is provided in the video—use this lesson as a supplemental reference.

What you'll learn

  • Set up a new backend server using Cloudflare Workers

  • Understand how an API enables the frontend and backend to communicate

  • Use the Wrangler CLI to initialize and manage your backend project files

  • Configure a cloud-based backend that can eventually be deployed publicly

  • Create a simple API endpoint for listing exercises

  • Centralize frontend-backend communication with a dedicated helper file

Lesson Overview

This lesson marks the transition from frontend development to building your application's backend. So far, your prototype has taken shape with interactive UI elements such as a calendar and meal selection. Now, you’ll establish a server that can handle requests and store information beyond a single browser session.

By introducing a backend API, you give your frontend the power to save and retrieve data—such as user-created workouts—even after a browser refresh. This is essential for any product that persists user data. You’ll begin by creating an API endpoint to serve exercise data, migrating it from the frontend to the backend for better data management and scalability.

You’ll use Cloudflare Workers, a modern approach to backend development that avoids the hassle of operating your own servers. This method is ideal for rapidly launching backend features, especially when you’re iterating quickly or scaling an early-stage product. The lesson is a helpful foundation for anyone building apps that require robust frontend-backend communication or plan to deploy projects to the web.

Who This Is For

This lesson is designed for learners who are ready to move their projects beyond a static or browser-only state.

  • Entrepreneurs wanting to create reliable, data-backed web apps
  • Product owners needing to manage user data securely
  • Early-stage developers interested in full stack best practices
  • Anyone looking for a straightforward way to set up cloud-based servers
  • Makers seeking to modernize prototypes with persistent storage
  • Teams aiming to structure frontend-backend communications for future scalability
Skill Leap AI For Business
  • Comprehensive, Business-Centric Curriculum
  • Fast-Track Your AI Skills
  • Build Custom AI Tools for Your Business
  • AI-Driven Visual & Presentation Creation

Where This Fits in a Workflow

Setting up a backend is a standard step when your app needs to store data or handle user actions server-side. In this workflow, you shift from handling everything in the browser to having a persistent location for core information—like available exercises or saved workouts.

For example, after building an interactive workout planner UI, you now need to ensure users’ progress isn’t lost when they leave or refresh the page. By building your backend server, you enable the UI to request and update exercise data through clearly defined API endpoints. Later, the same structure will allow you to add database functionality and advanced features without breaking the front end.

This lesson is a foundation for all subsequent backend-driven capabilities.

Technical & Workflow Benefits

Previously, you may have stored all information directly in the frontend or relied on static files. This only works until users expect persistent, user-specific data. Manually updating every change across the UI can introduce mistakes and inconsistencies.


Moving to a Cloudflare Workers backend gives you a clean API and standard way for your frontend to request or update information. The Wrangler CLI and server folder streamline your project organization, making deployments safer and development more predictable.

For instance, when you move the exercises data to the backend, any update there instantly syncs with every user interface—without manual updates. As your app grows, this architecture will save hours of debugging and let you scale or add features with much less friction.

Practice Exercise

To put this lesson into action, try centralizing UI communication and confirming connectivity:

  1. Create or locate a small list of exercise objects (e.g., “Squat”, “Pushup”, “Plank”) and move it from your frontend codebase to your backend server’s code.
  2. Use your new API endpoint to request these exercises from the UI. Confirm this works by refreshing the frontend and checking the network tab for a successful API response.
  3. Ask yourself: Did moving the data improve the ability to update or reuse it in different parts of your application?

This exercise will help reinforce the principle of separating data storage from your UI logic.

Course Context Recap

You’ve just taken the first major step into backend development by creating a working server and API for your project. Up to now, you focused on frontend features and design; now, your app is positioned for real data management.

In previous lessons, you set up interactivity and drafted your app’s core experience. Now, with an API in place, you’re set to make your application persistent and data-driven. Next, you’ll discover how to link your backend to a database, allowing users to truly store, retrieve, and manage their workouts through your app.

Ready to deepen your backend skills? Continue through the course for hands-on API and database integration techniques.