Rex Documentation

Differences from Next.js

Rex aims for API compatibility with Next.js while making different architectural choices. Here's what's the same, what's different, and what's new.

What works the same

  • File-system routingpages/ and app/ directories
  • Dynamic routes[param] and [...catchAll] segments
  • Data fetchinggetServerSideProps, getStaticProps
  • React Server Components"use client" directive, server/client split
  • _app.tsx and _document.tsx — custom app wrapper and document
  • Link component — client-side navigation with prefetching
  • Head component — inject tags into <head>
  • CSS Modules.module.css scoped styles
  • Middlewaremiddleware.ts with request/response modification
  • API routespages/api/*.ts handlers

What's not supported

FeatureReason
Edge RuntimeRex uses V8 isolates, not edge workers
i18n routingNot yet implemented
ISR (Incremental Static Regeneration)Static pages are built once at build time
Image Optimization APIPartial — rex/image provides <Image> with srcSet and blur placeholders, but not all next/image options are supported
Built-in caching layerNo opaque fetch cache — data fetching is explicit
next/font local loadingUse rex/font/google for Google Fonts

What's new in Rex

Rust performance

The server, router, and build pipeline are Rust-native. This means:

  • Faster cold starts — single binary, no Node.js boot
  • Lower memory — V8 isolates are lighter than full Node.js processes
  • Smaller Docker images — no node_modules on the server

Built-in tooling

Rex includes tools that Next.js requires separate packages for:

  • Lintingrex lint runs OxLint (no ESLint config needed)
  • Formattingrex fmt (no Prettier config needed)
  • Type checkingrex typecheck runs the TypeScript compiler

Custom server options

Beyond Node.js, Rex supports:

  • Rust custom server — embed Rex as a library in your own Axum server
  • NAPI bindings — use Rex from Node.js or Bun with native performance

MCP server

Rex can expose an MCP (Model Context Protocol) server, making your app accessible to AI agents and tools.

No vendor lock-in

Rex is open-source with no commercial platform dependency. Deploy anywhere that runs a Docker container or a Linux binary.