Skip to main content
Full Stack Radio

133: Sam Selikoff - Building Production-Ready SPAs Fast with Mirage.js

63 min episode · 2 min read
·

Episode

63 min

Read time

2 min

Topics

Product & Tech Trends

AI-Generated Summary

Key Takeaways

  • Development workflow integration: Mirage runs in the same process as your front-end application without requiring separate terminal tabs or port configurations. Import the library into your bootstrap file, instantiate the server in development mode, and define endpoints that intercept fetch requests while maintaining identical application code for production.
  • In-memory database layer: Mirage maintains referential integrity across route handlers through a shared JavaScript object database. Create data using factory patterns inspired by Rails' factory_bot, define relationships like director-has-many-movies, and mutations persist across navigation without managing foreign keys manually, enabling realistic multi-page workflows during development.
  • Testing and development code reuse: The same route handler definitions work in both development and testing environments. Tests start with an empty database and use server.create to set up specific scenarios, while development uses seed hooks. This eliminates duplicate mocking code and keeps tests focused on assertions rather than API implementation details.
  • Serializer layer flexibility: Mirage separates database conventions from API response formats through a serializer layer. Store data using camelCase JavaScript conventions internally, then configure serializers for JSON API, Active Model Serializer, or custom formats. Built-in serializers handle root keys, meta information, and relationship linking without changing database structure.
  • State management advantages: Front-end developers can define multiple data scenarios locally without coordinating shared staging environments or running complex back-end infrastructure. Switch between states like anonymous user, subscriber, or admin by changing variables in seed files. Hot module reloading applies data changes instantly without restarting servers or running database migrations.

What It Covers

Sam Selikoff explains Mirage.js, an API mocking tool that intercepts HTTP requests in JavaScript applications, enabling front-end developers to build production-ready features without waiting for back-end APIs by creating an in-memory database alongside their development workflow.

Key Questions Answered

  • Development workflow integration: Mirage runs in the same process as your front-end application without requiring separate terminal tabs or port configurations. Import the library into your bootstrap file, instantiate the server in development mode, and define endpoints that intercept fetch requests while maintaining identical application code for production.
  • In-memory database layer: Mirage maintains referential integrity across route handlers through a shared JavaScript object database. Create data using factory patterns inspired by Rails' factory_bot, define relationships like director-has-many-movies, and mutations persist across navigation without managing foreign keys manually, enabling realistic multi-page workflows during development.
  • Testing and development code reuse: The same route handler definitions work in both development and testing environments. Tests start with an empty database and use server.create to set up specific scenarios, while development uses seed hooks. This eliminates duplicate mocking code and keeps tests focused on assertions rather than API implementation details.
  • Serializer layer flexibility: Mirage separates database conventions from API response formats through a serializer layer. Store data using camelCase JavaScript conventions internally, then configure serializers for JSON API, Active Model Serializer, or custom formats. Built-in serializers handle root keys, meta information, and relationship linking without changing database structure.
  • State management advantages: Front-end developers can define multiple data scenarios locally without coordinating shared staging environments or running complex back-end infrastructure. Switch between states like anonymous user, subscriber, or admin by changing variables in seed files. Hot module reloading applies data changes instantly without restarting servers or running database migrations.

Notable Moment

Selikoff reveals that some development teams have successfully deployed Mirage-powered prototypes to production using local storage for persistence, creating fully functional demos for sales teams. Future plans include generating real Node.js back-end servers directly from Mirage definitions, potentially eliminating the need to manually build APIs for data-driven applications.

Know someone who'd find this useful?

You just read a 3-minute summary of a 60-minute episode.

Get Full Stack Radio summarized like this every Monday — plus up to 2 more podcasts, free.

Pick Your Podcasts — Free

Keep Reading

More from Full Stack Radio

We summarize every new episode. Want them in your inbox?

Similar Episodes

Related episodes from other podcasts

Explore Related Topics

This podcast is featured in Best Cybersecurity Podcasts (2026) — ranked and reviewed with AI summaries.

You're clearly into Full Stack Radio.

Every Monday, we deliver AI summaries of the latest episodes from Full Stack Radio and 192+ other podcasts. Free for up to 3 shows.

Start My Monday Digest

No credit card · Unsubscribe anytime