Jack Hsu 84796d011e
docs(misc): add titles to intro/overview pages (#31636)
## Current Behavior

- Documentation pages under "technologies" and "core-api" sections with
"introduction"/"overview" IDs lack H1 titles after front matter
- Some remote caching package links point to parent sections instead of
overview pages

## Expected Behavior

- All affected documentation pages should have H1 titles for consistency
- Links should point directly to overview pages

## Related Issue(s)

Fixes #

## Changes Made

### 1. Updated Remote Caching Links (commit fae9055f8c)

Updated links in 3 files to point directly to overview pages:
- `docs/blog/2025-01-06-nx-update-20-3.md`
- `docs/shared/deprecated/custom-tasks-runner.md`
- `docs/shared/recipes/running-tasks/self-hosted-caching.md`

Changed links from:
- `/reference/core-api/azure-cache` →
`/reference/core-api/azure-cache/overview`
- `/reference/core-api/gcs-cache` →
`/reference/core-api/gcs-cache/overview`
- `/reference/core-api/s3-cache` →
`/reference/core-api/s3-cache/overview`
- `/reference/core-api/shared-fs-cache` →
`/reference/core-api/shared-fs-cache/overview`

### 2. Added H1 Titles to Documentation Pages

Added H1 titles to 29 documentation files that were missing them:

#### Core API Overview Pages (6 files)
- `docs/shared/packages/azure-cache/azure-cache-plugin.md` → `#
@nx/azure-cache`
- `docs/shared/packages/conformance/conformance-plugin.md` → `#
@nx/conformance`
- `docs/shared/packages/gcs-cache/gcs-cache-plugin.md` → `#
@nx/gcs-cache`
- `docs/shared/packages/owners/owners-plugin.md` → `# @nx/owners`
- `docs/shared/packages/s3-cache/s3-cache-plugin.md` → `# @nx/s3-cache`
- `docs/shared/packages/shared-fs-cache/shared-fs-cache-plugin.md` → `#
@nx/shared-fs-cache`

#### Technology Introduction Pages (23 files)
- `docs/shared/packages/angular/angular-plugin.md` → `# @nx/angular`
- `docs/shared/packages/esbuild/esbuild-plugin.md` → `# @nx/esbuild`
- `docs/shared/packages/rspack/rspack-plugin.md` → `# @nx/rspack`
- `docs/shared/packages/vite/vite-plugin.md` → `# @nx/vite`
- `docs/shared/packages/webpack/plugin-overview.md` → `# @nx/webpack`
- `docs/shared/packages/eslint/eslint.md` → `# @nx/eslint`
- `docs/shared/packages/gradle/gradle-plugin.md` → `# @nx/gradle`
- `docs/shared/packages/express/express-plugin.md` → `# @nx/express`
- `docs/shared/packages/node/node-plugin.md` → `# @nx/node`
- `docs/shared/packages/nest/nest-plugin.md` → `# @nx/nest`
- `docs/shared/packages/expo/expo-plugin.md` → `# @nx/expo`
- `docs/shared/packages/react/react-plugin.md` → `# @nx/react`
- `docs/shared/packages/next/plugin-overview.md` → `# @nx/next`
- `docs/shared/packages/react-native/react-native-plugin.md` → `#
@nx/react-native`
- `docs/shared/packages/remix/remix-plugin.md` → `# @nx/remix`
- `docs/shared/packages/cypress/cypress-plugin.md` → `# @nx/cypress`
- `docs/shared/packages/detox/detox-plugin.md` → `# @nx/detox`
- `docs/shared/packages/jest/jest-plugin.md` → `# @nx/jest`
- `docs/shared/packages/playwright/playwright-plugin.md` → `#
@nx/playwright`
- `docs/shared/packages/storybook/plugin-overview.md` → `#
@nx/storybook`
- `docs/shared/packages/js/js-plugin.md` → `# @nx/js`
- `docs/shared/packages/vue/vue-plugin.md` → `# @nx/vue`
- `docs/shared/packages/nuxt/nuxt-plugin.md` → `# @nx/nuxt`

Note: The Angular Rspack introduction page
(`docs/shared/guides/angular-rspack/introduction.md`) already had an
appropriate H1
title "# Introduction" and was left unchanged.

All changes improve documentation consistency and navigation by ensuring
proper titles and direct links to overview pages.
2025-06-18 09:50:44 -04:00

278 lines
7.8 KiB
Markdown

---
title: Overview of the Nx Remix Plugin
description: The Nx Plugin for Remix contains executors, generators, and utilities for managing Remix applications and libraries within an Nx workspace.
---
# @nx/remix
The Nx Plugin for Remix contains executors, generators, and utilities for managing Remix applications and libraries
within an Nx workspace. It provides:
- Integration with libraries such as Storybook, Jest, Vitest, Playwright and Cypress.
- Generators to help scaffold code quickly, including:
- Libraries, both internal to your codebase and publishable to npm
- Routes
- Loaders
- Actions
- Meta
- Utilities for automatic workspace refactoring.
## Setting up @nx/remix
### Installation
{% callout type="note" title="Keep Nx Package Versions In Sync" %}
Make sure to install the `@nx/remix` version that matches the version of `nx` in your repository. If the version numbers get out of sync, you can encounter some difficult to debug errors. You can [fix Nx version mismatches with this recipe](/recipes/tips-n-tricks/keep-nx-versions-in-sync).
{% /callout %}
In any Nx workspace, you can install `@nx/remix` by running the following command:
```shell {% skipRescope=true %}
nx add @nx/remix
```
This will install the correct version of `@nx/remix`.
### How @nx/remix Infers Tasks
The `@nx/remix` plugin will create a task for any project that has a Remix configuration file present. Any of the following files will be recognized as a Remix configuration file:
- `remix.config.js`
- `remix.config.mjs`
- `remix.config.cjs`
### View Inferred Tasks
To view inferred tasks for a project, open the [project details view](/concepts/inferred-tasks) in Nx Console or run `nx show project my-project --web` in the command line.
### @nx/remix Configuration
The `@nx/remix/plugin` is configured in the `plugins` array in `nx.json`.
```json {% fileName="nx.json" %}
{
"plugins": [
{
"plugin": "@nx/remix/plugin",
"options": {
"buildTargetName": "build",
"devTargetName": "dev",
"startTargetName": "start",
"typecheckTargetName": "typecheck"
}
}
]
}
```
The `buildTargetName`, `devTargetName`, `startTargetName` and `typecheckTargetName` options control the names of the inferred Remix tasks. The default names are `build`, `dev`, `start` and `typecheck`.
## Using the Remix Plugin
## Generate a Remix Application
```{% command="nx g @nx/remix:app apps/myapp" path="~/acme" %}
NX Generating @nx/remix:application
✔ What unit test runner should be used? · vitest
✔ Which E2E test runner would you like to use? · playwright
UPDATE package.json
UPDATE nx.json
CREATE apps/myapp/project.json
CREATE apps/myapp/README.md
CREATE apps/myapp/app/nx-welcome.tsx
CREATE apps/myapp/app/root.tsx
CREATE apps/myapp/app/routes/_index.tsx
CREATE apps/myapp/public/favicon.ico
CREATE apps/myapp/remix.config.js
CREATE apps/myapp/remix.env.d.ts
CREATE apps/myapp/tests/routes/_index.spec.tsx
CREATE apps/myapp/tsconfig.app.json
CREATE apps/myapp/tsconfig.json
CREATE apps/myapp/.gitignore
CREATE apps/myapp/package.json
CREATE apps/myapp/tsconfig.spec.json
CREATE apps/myapp/vitest.config.ts
CREATE apps/myapp/test-setup.ts
CREATE apps/myapp/.eslintrc.json
CREATE apps/myapp/.eslintignore
CREATE apps/myapp-e2e/project.json
CREATE apps/myapp-e2e/src/example.spec.ts
CREATE apps/myapp-e2e/playwright.config.ts
CREATE apps/myapp-e2e/tsconfig.json
CREATE apps/myapp-e2e/.eslintrc.json
```
## Build, Serve and Test your Application
1. To build your application run:
```{% command="nx build myapp" path="~/acme" %}
> nx run myapp:build
Building Remix app in production mode...
Built in 857ms
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
NX Successfully ran target build for project myapp (3s)
```
2. To serve your application for use during development run:
```{% command="nx dev myapp" path="~/acme" %}
> nx run myapp:dev
> remix dev --manual
💿 remix dev
info building...
info built (388ms)
[remix-serve] http://localhost:3000 (http://192.168.0.12:3000)
```
3. To test the application using vitest run:
```{% command="nx test myapp" path="~/acme" %}
> nx run myapp:test
> vitest
RUN v1.6.0 /Users/columferry/dev/nrwl/issues/gh_issues/nx26943/apps/myapp
✓ tests/routes/_index.spec.tsx (1)
✓ renders loader data
Test Files 1 passed (1)
Tests 1 passed (1)
Start at 13:22:54
Duration 533ms (transform 47ms, setup 68ms, collect 123ms, tests 36ms, environment 204ms, prepare 35ms)
———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
NX Successfully ran target test for project myapp (950ms)
```
## Generating an Nx Library
When developing your application, it often makes sense to split your codebase into smaller more focused libraries.
To generate a library to use in your Remix application run:
```{% command="nx g @nx/remix:lib libs/login" path="~/acme" %}
NX Generating @nx/remix:library
✔ What test runner should be used? · vitest
UPDATE nx.json
UPDATE package.json
CREATE babel.config.json
CREATE libs/login/project.json
CREATE libs/login/.eslintrc.json
CREATE libs/login/README.md
CREATE libs/login/src/index.ts
CREATE libs/login/tsconfig.lib.json
CREATE libs/login/tsconfig.json
CREATE libs/login/vite.config.ts
CREATE libs/login/tsconfig.spec.json
CREATE libs/login/src/lib/login.module.css
CREATE libs/login/src/lib/login.spec.tsx
CREATE libs/login/src/lib/login.tsx
UPDATE tsconfig.base.json
CREATE libs/login/src/test-setup.ts
CREATE libs/login/src/server.ts
```
You can then use the library by importing one of the exports into your application:
`apps/myapp/app/routes/index.tsx`
```tsx
import { Login } from '@acme/login';
export default function Index() {
return (
<div>
<Login />
</div>
);
}
```
You can also run test on your library:
`nx test login`
## Generating a Route
To generate a route for your application:
```{% command="nx g @nx/remix:route apps/myapp/app/routes/admin" path="~/acme" %}
NX Generating @nx/remix:route
CREATE apps/myapp/app/routes/admin.tsx
CREATE apps/myapp/app/styles/admin.css
```
## Using a loader from your Library
To use a Route Loader where the logic lives in your library, follow the steps below.
1. Generate a loader for your route:
```{% command="nx g @nx/remix:loader apps/myapp/app/routes/admin.tsx" path="~/acme" %}
NX Generating @nx/remix:loader
UPDATE apps/myapp/app/routes/admin.tsx
```
2. Add a new file in your `login` lib
`libs/login/src/lib/admin/admin.loader.ts`
```ts
import { json, LoaderFunctionArgs } from '@remix-run/node';
export const adminLoader = async ({ request }: LoaderFunctionArgs) => {
return json({
message: 'Hello, world!',
});
};
```
Export the function from the `libs/login/src/server.ts` file:
```ts
export * from './lib/admin/admin.loader';
```
3. Use the loader in your `apps/myapp/app/routes/admin.tsx`
Replace the default loader code:
```tsx
export const loader = async ({ request }: LoaderFunctionArgs) => {
return json({
message: 'Hello, world!',
});
};
```
with
```tsx
import { adminLoader } from '@acme/login/server';
export const loader = adminLoader;
```
## GitHub Repository with Example
You can see an example of an Nx Workspace using Remix by clicking below.
{% github-repository url="https://github.com/nrwl/nx-recipes/tree/main/remix" /%}