Skip to content

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.

Terminal window
nx add @nx/remix

Verify the plugin is setup:

  1. Check for @nx/remix listed as a plugin:

    Terminal window
    nx report
  2. Ensure inferred project targets are working:

    Terminal window
    nx show projects --with-target=build
  3. Inspect a specific project configuration for the inferred targets:

    Terminal window
    nx show project my-remix-app
Terminal window
nx g @nx/remix:app apps/my-app

To start the application in development mode, run nx dev my-app. Read more about the options available for the application generator.

When developing your application, it often makes sense to split your codebase into smaller, more focused libraries.

Terminal window
nx g @nx/remix:lib libs/my-lib

Read 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.

Terminal window
nx g @nx/remix:route apps/my-app/app/routes/admin

This 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.

Terminal window
nx g @nx/remix:loader apps/my-app/app/routes/admin
nx g @nx/remix:action apps/my-app/app/routes/admin
nx g @nx/remix:meta apps/my-app/app/routes/admin

These generators add loader, action, and meta functions to existing route files. Read more about the options available for the loader, action, and meta generators.

Terminal window
nx dev my-app

This starts the Remix development server with hot module replacement at http://localhost:3000.

Terminal window
nx build my-app

Compiles the application for production deployment. The output is written to the build directory inside your project folder by default.

Terminal window
nx start my-app

Serves the production build using remix-serve. Depends on build completing first.

Import library code directly into your route files:

apps/my-app/app/routes/_index.tsx
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:

libs/my-lib/src/server.ts
export { myLoader } from './lib/my-loader';
apps/my-app/app/routes/admin.tsx
import { myLoader } from '@myorg/my-lib/server';
export const loader = myLoader;

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.js
  • remix.config.mjs
  • remix.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.

Configure @nx/remix/plugin in the plugins array in nx.json:

nx.json
{
"plugins": [
{
"plugin": "@nx/remix/plugin",
"options": {
"buildTargetName": "build",
"devTargetName": "dev",
"startTargetName": "start",
"typecheckTargetName": "typecheck"
}
}
]
}
OptionDescriptionDefault
buildTargetNameName of the production build taskbuild
devTargetNameName of the development server taskdev
startTargetNameName of the production server taskstart
typecheckTargetNameName of the typecheck tasktypecheck

Use include/exclude glob patterns in the plugin configuration:

nx.json
{
"plugins": [
{
"plugin": "@nx/remix/plugin",
"include": ["apps/**/*"],
"exclude": ["apps/legacy-app/**/*"],
"options": {
"buildTargetName": "build",
"devTargetName": "dev",
"startTargetName": "start",
"typecheckTargetName": "typecheck"
}
}
]
}

To see what tasks Nx inferred for a project:

Terminal window
nx show project my-app

Or open the project details view in Nx Console.

See Set Up CI for a complete CI configuration guide.

Terminal window
nx affected -t build test typecheck lint

This 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.

Share build and typecheck cache results across your team and CI with remote caching:

Terminal window
nx connect