Skip to main content
In this tutorial, you’ll build a complete todo application with a React frontend using Inertia.js. You’ll learn how to connect your Rust backend to a modern React UI.

What We’re Building

A full-featured todo app with:
  • List all todos
  • Create new todos
  • Mark todos as complete
  • Edit and delete todos
  • All without writing a single API endpoint

Prerequisites

This creates a project with React and Inertia pre-configured.

Step 1: Create the Migration

Edit the migration:
Run migrations:

Step 2: Create the Controller

Edit src/controllers/todos.rs:

Step 3: Define Routes

Edit src/routes.rs:

Step 4: Generate TypeScript Types

This creates two files for end-to-end type safety:

Props Types (frontend/src/types/inertia-props.ts)

Route Types (frontend/src/types/routes.ts)

Now you have full type safety from backend routes to frontend navigation!

Step 5: Create React Components

Index Page

Create frontend/src/pages/Todos/Index.tsx:

Create Page

Create frontend/src/pages/Todos/Create.tsx:

Edit Page

Create frontend/src/pages/Todos/Edit.tsx:

Step 6: Run the App

Start the development server:
Visit http://localhost:8080/todos to see your todo app in action!

How It Works

  1. No API Layer: The Rust backend returns Inertia responses directly to React components
  2. End-to-End Type Safety: TypeScript types are generated from Rust structs for both props AND routes
  3. Type-Safe Routes: No magic strings - controllers.todos.toggle({ id }) instead of '/todos/${id}/toggle'
  4. SPA Navigation: Page transitions happen without full page reloads
  5. Forms: <Form> component accepts route objects directly (Inertia v2+ UrlMethodPair compatible)
  6. Redirects: After mutations, redirect to update the UI

Key Inertia Features Used

Summary

You’ve built a complete CRUD application with end-to-end type safety:
  • Database migrations and models
  • Server-side controllers with Inertia responses
  • React pages with type-safe props
  • Type-safe routes with controllers object (no magic strings!)
  • Forms with <Form> component and validation feedback
  • Type-safe navigation

Next Steps

  • Add user authentication
  • Implement optimistic updates
  • Add toast notifications
  • Deploy to production