The Remix plugin for Nx, @nx/remix, automatically infers build, dev, start, and typecheck tasks from your Remix configuration and provides generators for applications, libraries, routes, loaders, actions, and meta functions.
You don't need the plugin to use Remix with Nx. Any project already benefits from caching, task orchestration, and the project graph. The plugin adds automatic task inference, route scaffolding, and simplified configuration.
Setting Up @nx/remix
Section titled “Setting Up @nx/remix”Add to an Existing Nx Workspace
Section titled “Add to an Existing Nx Workspace”nx add @nx/remixVerify the plugin is setup:
Check for
@nx/remixlisted as a plugin:Terminal window nx reportEnsure inferred project targets are working:
Terminal window nx show projects --with-target=buildInspect a specific project configuration for the inferred targets:
Terminal window nx show project my-remix-app
Generate a New Application
Section titled “Generate a New Application”nx g @nx/remix:app apps/my-appTo start the application in development mode, run nx dev my-app. Read more about the options available for the application generator.
Generate a Library
Section titled “Generate a Library”When developing your application, it often makes sense to split your codebase into smaller, more focused libraries.
nx g @nx/remix:lib libs/my-libRead more about the options available for the library generator. Libraries let you share code between applications, enforce architectural boundaries with the project graph, and speed up CI by only rebuilding what changed.
Develop Remix Applications
Section titled “Develop Remix Applications”Generate Routes
Section titled “Generate Routes”nx g @nx/remix:route apps/my-app/app/routes/adminThis creates a new route file in your application's routes directory following Remix's file-based routing conventions. Read more about the options available for the route generator.
Add Loaders, Actions, and Meta
Section titled “Add Loaders, Actions, and Meta”nx g @nx/remix:loader apps/my-app/app/routes/adminnx g @nx/remix:action apps/my-app/app/routes/adminnx g @nx/remix:meta apps/my-app/app/routes/adminThese generators add loader, action, and meta functions to existing route files. Read more about the options available for the loader, action, and meta generators.
Serve for Development
Section titled “Serve for Development”nx dev my-appThis starts the Remix development server with hot module replacement at http://localhost:3000.
Build for Production
Section titled “Build for Production”nx build my-appCompiles the application for production deployment. The output is written to the build directory inside your project folder by default.
Start Production Server
Section titled “Start Production Server”nx start my-appServes the production build using remix-serve. Depends on build completing first.
Use Libraries in Your Application
Section titled “Use Libraries in Your Application”Import library code directly into your route files:
import { MyComponent } from '@myorg/my-lib';
export default function Index() { return <MyComponent />;}You can also use library code in loaders by exporting from a separate server entry point:
export { myLoader } from './lib/my-loader';import { myLoader } from '@myorg/my-lib/server';
export const loader = myLoader;Configure @nx/remix
Section titled “Configure @nx/remix”How @nx/remix Infers Tasks
Section titled “How @nx/remix Infers Tasks”The @nx/remix plugin creates tasks for any project that has a Remix configuration file. The plugin recognizes two setups:
Classic Remix Compiler -- looks for any of the following files:
remix.config.jsremix.config.mjsremix.config.cjs
Remix with Vite -- looks for vite.config.{js,ts,mjs,mts,cjs,cts} files that import the Remix plugin from @remix-run/dev.
Plugin Options
Section titled “Plugin Options”Configure @nx/remix/plugin in the plugins array in nx.json:
{ "plugins": [ { "plugin": "@nx/remix/plugin", "options": { "buildTargetName": "build", "devTargetName": "dev", "startTargetName": "start", "typecheckTargetName": "typecheck" } } ]}| Option | Description | Default |
|---|---|---|
buildTargetName | Name of the production build task | build |
devTargetName | Name of the development server task | dev |
startTargetName | Name of the production server task | start |
typecheckTargetName | Name of the typecheck task | typecheck |
Exclude or Include Specific Projects
Section titled “Exclude or Include Specific Projects”Use include/exclude glob patterns in the plugin configuration:
{ "plugins": [ { "plugin": "@nx/remix/plugin", "include": ["apps/**/*"], "exclude": ["apps/legacy-app/**/*"], "options": { "buildTargetName": "build", "devTargetName": "dev", "startTargetName": "start", "typecheckTargetName": "typecheck" } } ]}View Inferred Tasks
Section titled “View Inferred Tasks”To see what tasks Nx inferred for a project:
nx show project my-appOr open the project details view in Nx Console.
CI Considerations
Section titled “CI Considerations”See Set Up CI for a complete CI configuration guide.
Build and Test Only What Changed
Section titled “Build and Test Only What Changed”nx affected -t build test typecheck lintThis uses the project graph to determine which projects are affected by your changes and only runs tasks for those. Read more about the benefits of nx affected.
Remote Caching
Section titled “Remote Caching”Share build and typecheck cache results across your team and CI with remote caching:
nx connect