← 返回 Skills 市场
anderskev

Remix V2 Routing

作者 Kevin Anderson · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
15
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install remix-v2-routing
功能描述
Remix v2 routing patterns. Use when implementing flat-routes v2 conventions, route file naming, nested layouts, resource routes, or root.tsx scaffolding. Tri...
使用说明 (SKILL.md)

Remix v2 Routing

Quick Reference

Flat-routes v2 filename rules (all files live in app/routes/):

_index.tsx                 → /
concerts.tsx               → /concerts                (acts as layout when dotted children exist; otherwise leaf for /concerts)
concerts._index.tsx        → /concerts                (renders under layout)
concerts.$city.tsx         → /concerts/:city          params.city
concerts.trending.tsx      → /concerts/trending
_auth.tsx + _auth.login.tsx → /login (pathless layout, no URL segment)
files.$.tsx                → /files/*                 params["*"]
($lang)._index.tsx         → / and /en (or /fr etc.) — optional segment
sitemap[.]xml.tsx          → /sitemap.xml             (escape literal)
concerts_.mine.tsx         → /concerts/mine           (opts out of layout)
dashboard/route.tsx        → /dashboard               (folder + route.tsx)
reports.$id[.pdf].tsx      → /reports/:id.pdf         (no default export = resource)

Imports — always use @remix-run/react, never react-router-dom:

import { Outlet, Link, useLoaderData, useParams } from "@remix-run/react";
import type { LoaderFunctionArgs } from "@remix-run/node"; // or /cloudflare, /deno

File Naming Conventions

Dots in filenames create URL slashes and parent/child nesting. Underscore prefix marks pathless segments (_auth.tsx) and index routes (_index.tsx). Trailing underscore (concerts_.mine.tsx) opts out of layout nesting while keeping the URL nested. Brackets escape literal characters: sitemap[.]xml.tsx. Splat is the single dollar sign: $.tsx exposes the rest of the path under params["*"]. Optional segments are wrapped in parens: ($lang).

See references/conventions.md for the full table and edge cases.

Nested Layouts

A parent module (concerts.tsx) renders \x3COutlet />; child routes (concerts.$city.tsx, concerts._index.tsx) mount inside it automatically based on the dot-delimited filename.

// app/routes/concerts.tsx
import { Outlet } from "@remix-run/react";

export default function ConcertsLayout() {
  return (
    \x3Csection>
      \x3Cnav>{/* concerts subnav */}\x3C/nav>
      \x3COutlet />
    \x3C/section>
  );
}
// app/routes/concerts._index.tsx  (renders at exactly /concerts)
export default function ConcertsIndex() {
  return \x3Ch1>Browse concerts\x3C/h1>;
}

For a layout with no URL contribution, prefix with a single underscore:

// app/routes/_auth.tsx          → wraps /login, /signup; no URL segment
// app/routes/_auth.login.tsx    → /login   (inherits _auth layout)
// app/routes/_auth.signup.tsx   → /signup

Dynamic Segments and Splats

$name captures a single segment; $.tsx captures the rest of the path. Loader receives values via params:

// app/routes/concerts.$city.tsx
import type { LoaderFunctionArgs } from "@remix-run/node";
import { json } from "@remix-run/node";
import { useLoaderData } from "@remix-run/react";

export async function loader({ params }: LoaderFunctionArgs) {
  if (!params.city) throw new Response("Not found", { status: 404 });
  return json({ city: params.city });
}

export default function City() {
  const { city } = useLoaderData\x3Ctypeof loader>();
  return \x3Ch1>{city}\x3C/h1>;
}

Splat values live under "*" — there is no params.splat:

// app/routes/files.$.tsx
export async function loader({ params }: LoaderFunctionArgs) {
  const rest = params["*"]; // bracket access only
  return new Response(await readBlob(rest), { headers: { "Content-Type": "application/octet-stream" } });
}

Root Module

app/root.tsx is the only required route. It owns the document shell and must render \x3CMeta />, \x3CLinks />, \x3COutlet />, \x3CScrollRestoration />, \x3CScripts />, and (during dev) \x3CLiveReload />. See references/root.md.

Resource Routes

A route module without a default export is a resource route — it returns raw Response objects (PDF, JSON, RSS, webhooks). Parent loaders do not run, and \x3CLink> must use reloadDocument (or be replaced with \x3Ca>) to trigger a real document request. See references/resource-routes.md.

Gates (decision sequencing)

Answer in order. Pass means the condition is true; pick the answer on the same line and stop.

Layout vs flat URL

  1. Is there shared chrome at all (nav, breadcrumbs, sidebar) at this level?
    • Fail → Use plain dotted segments (about.tsx, pricing.tsx); no layout module needed. Stop.
    • Pass → Step 1.
  2. Should this URL share UI (nav, breadcrumbs, sidebar) with a parent path?
    • Pass → Use dot-delimited nesting (concerts.$city.tsx under concerts.tsx). Stop.
    • Fail → Step 2.
  3. Does the URL just happen to be nested but should render standalone?
    • Pass → Trailing underscore (concerts_.mine.tsx). Stop.
    • Fail → Step 3.
  4. Need a wrapper layout but no parent URL segment?
    • Pass → Single-underscore pathless parent (_auth.tsx + _auth.login.tsx). Stop.

UI route vs resource route

  1. Does this URL ever render HTML to a user?
    • Pass → Export a default component. UI route. Stop.
    • Fail → Step 2.
  2. Returns JSON, PDF, RSS, sitemap, webhook, or other raw Response?
    • Pass → Omit default export — module becomes a resource route. Use reloadDocument on any \x3CLink> pointing to it. Stop.

_index.tsx vs index.tsx

  1. On Remix v2 with flat-routes?
    • Pass → _index.tsx (leading underscore). Stop.
    • Fail → Step 2 — you're on v1 (or using the v1 fallback adapter).
  2. Need to keep a v1 nested-folder tree alive?

Additional Documentation

  • Conventions: See references/conventions.md for the full filename grammar (_index, _layout, $param, splat, optional, escape, folder + route.tsx, trailing underscore).
  • Root module: See references/root.md for the root.tsx scaffold and the required document elements.
  • Resource routes: See references/resource-routes.md for non-HTML responses, the no-default-export rule, parent-loader skipping, and reloadDocument.
  • v1 → v2 migration: See references/v1-migration.md for differences from v1 (__double underscore folders, index.tsx, @remix-run/v1-route-convention, ignoredRouteFiles).

v1 vs v2 Convention Comparison

Concern v1 (nested folders) v2 (flat routes)
Index route index.tsx _index.tsx
Pathless layout __auth/ (double underscore) _auth.tsx (single)
Nested URL folder hierarchy dot delimiter in filename
Dynamic segment $param.tsx $param.tsx (unchanged)
Splat $.tsx $.tsx (unchanged)
Escape literal n/a [.], [] brackets
Opt-out of layout move out of folder trailing _ (foo_.bar.tsx)
Co-location adjacent files in folder feature/route.tsx + siblings
Fallback adapter n/a @remix-run/v1-route-convention
安全使用建议
Safe to install for Remix routing help. Review generated route and config changes as usual, especially resource routes and migration adapter use, because those can affect application behavior.
能力标签
requires-oauth-tokenrequires-sensitive-credentials
能力评估
Purpose & Capability
The artifacts consistently provide Remix v2 routing guidance, examples, and migration notes; the code snippets are normal framework examples and match the stated purpose.
Instruction Scope
Instructions are scoped to route naming, Remix imports, root modules, resource routes, and migration choices; no role changes, hidden directives, or output manipulation were found.
Install Mechanism
The package contains only markdown files with non-executable permissions; the only install command shown is an optional Remix v1 route adapter for migration.
Credentials
Using the skill may lead an agent to edit Remix app route files or config, which is expected for this purpose and not broader than the documented routing task.
Persistence & Privilege
No background workers, persistence hooks, privilege escalation, local profile access, credential handling, or session-store use appear in the artifacts.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install remix-v2-routing
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /remix-v2-routing 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
remix-v2-routing 1.0.0 - Initial release with comprehensive documentation for Remix v2 routing patterns. - Details flat-routes v2 filename conventions, including dynamic segments, splats, optional segments, and resource routes. - Explains nested layouts, pathless layouts, and trailing underscore patterns for opting out of layout nesting. - Provides guidance for root module requirements and resource route behavior. - Includes decision gates for choosing between layout, flat, pathless, UI, and resource routes. - Offers comparison chart between v1 and v2 conventions and links to further references for conventions, migration, and special cases.
元数据
Slug remix-v2-routing
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Remix V2 Routing 是什么?

Remix v2 routing patterns. Use when implementing flat-routes v2 conventions, route file naming, nested layouts, resource routes, or root.tsx scaffolding. Tri... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 15 次。

如何安装 Remix V2 Routing?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install remix-v2-routing」即可一键安装,无需额外配置。

Remix V2 Routing 是免费的吗?

是的,Remix V2 Routing 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Remix V2 Routing 支持哪些平台?

Remix V2 Routing 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Remix V2 Routing?

由 Kevin Anderson(@anderskev)开发并维护,当前版本 v1.0.0。

💬 留言讨论