CodeSampleX

Sample

react-router-dom 6.30.4: createMemoryRouter

Verified sample for npm react-router-dom 6.30.4: createMemoryRouter. The contract ran on node 22 · linux alpine/x64 · docker and passed.

sha256:81bfc3b99cbdfe55d2c435087ec36f92330fd758e5eb5c96e4fd8747ad9049c3

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Verification-run environments

Environment Contract Stages Run
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5…
2026-08-25

Case

HOW
Goal
verify react-router-dom.createMemoryRouter in pkg:npm/react-router-dom@6.30.4
Packages
Symbols
  • createMemoryRouter
Environment
node 22.23.2
Created
2026-08-25T12:17:17Z

Contract

  1. assert createMemoryRouter creates in-memory router with initial entries and active state matches
  2. assert router.navigate updates the current location pathname and active matches
  3. assert matchRoutes matches route hierarchies against a pathname and extracts route params
  4. assert generatePath replaces path parameters in path patterns
  5. assert createSearchParams creates URLSearchParams from key-value pairs

Files

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • test/contract.js

Download the source artifact (tar.gz)

Source

PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify react-router-dom.createMemoryRouter in pkg:npm/react-router-dom@6.30.4
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/react-router-dom@6.30.4
Demonstrate these symbols/APIs:
  - createMemoryRouter
Required runtime conditions:
  - ecosystem: golang
  - language: go
  - packageManager: go@1.26.6
  - runtime: go@1.26.6

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:62c21c034d14dd858b34e0e4195a2c25431941204198d795a5d6168436406c21","contract":["assert createMemoryRouter creates in-memory router with initial entries and active state matches","assert router.navigate updates the current location pathname and active matches","assert matchRoutes matches route hierarchies against a pathname and extracts route params","assert generatePath replaces path parameters in path patterns","assert createSearchParams creates URLSearchParams from key-value pairs"],"goal":"verify react-router-dom.createMemoryRouter in pkg:npm/react-router-dom@6.30.4","kind":"HOW","packages":["pkg:npm/react-router-dom@6.30.4"],"schemaVersion":1,"symbols":["createMemoryRouter"]},"contractCommand":["node","test/contract.js"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/react-router-dom@6.30.4"],"schemaVersion":1,"subject":"pkg:npm/react-router-dom@6.30.4","symbols":["createMemoryRouter"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-react-router-dom-verify",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-react-router-dom-verify",
      "version": "1.0.0",
      "dependencies": {
        "react-router-dom": "6.30.4"
      }
    },
    "node_modules/@remix-run/router": {
      "version": "1.23.3",
      "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.23.3.tgz",
      "integrity": "sha512-4An71tdz9X8+3sI4Qqqd2LWd9vS39J7sqd9EU4Scw7TJE/qB10Flv/UuqbPVgfQV9XoK8Np6jNquZitnZq5i+Q==",
      "license": "MIT",
      "engines": {
        "node": ">=14.0.0"
      }
    },
    "node_modules/react": {
      "version": "19.2.8",
      "resolved": "https://registry.npmjs.org/react/-/react-19.2.8.tgz",
      "integrity": "sha512-PWaYA1L/q9u2u7xYQi+Y3L3Yfnie7XyLeaJICV1MGD6LprsBxcAqGjYyr0eY3p+QdsA+x/Irkt4Qif8D63+Sbw==",
      "license": "MIT",
      "peer": true,
      "engines": {
        "node": ">=0.10.0"
      }
    },
    "node_modules/react-dom": {
      "version": "19.2.8",
      "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.8.tgz",
      "integrity": "sha512-rVprimfGBG3DR+Tq0IQG2DT5PxKth1WIGDmj5yPmlzr4YBe7uyE+Du4oVqTDXZSHGGGXRtTJEGSSePyQCMBglQ==",
      "license": "MIT",
      "peer": true,
      "dependencies": {
        "scheduler": "^0.27.0"
      },
      "peerDependencies": {
        "react": "^19.2.8"
      }
    },
    "node_modules/react-router": {
      "version": "6.30.4",
      "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.30.4.tgz",
      "integrity": "sha512-SVUsDe+DybHM/WmYKIVYhZh1o5Dcuf16yM6WjG02Q9XVFMZIJyHYhwrr6bFBXZkVP6z69kNkMyBCujt8FaFLJA==",
      "license": "MIT",
      "dependencies": {
        "@remix-run/router": "1.23.3"
      },
      "engines": {
        "node": ">=14.0.0"
      },
      "peerDependencies": {
        "react": ">=16.8"
      }
    },
    "node_modules/react-router-dom": {
      "version": "6.30.4",
      "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.30.4.tgz",
      "integrity": "sha512-q4HvNl+mmDdkS0g+MqiBZNteQJCuimWoOyHMy4T/RQLAn9Z29+E91QXRaxOujeMl2HTzRSS0KFPd7lxX3PjV0Q==",
      "license": "MIT",
      "dependencies": {
        "@remix-run/router": "1.23.3",
        "react-router": "6.30.4"
      },
      "engines": {
        "node": ">=14.0.0"
      },
      "peerDependencies": {
        "react": ">=16.8",
        "react-dom": ">=16.8"
      }
    },
    "node_modules/scheduler": {
      "version": "0.27.0",
      "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.27.0.tgz",
      "integrity": "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==",
      "license": "MIT",
      "peer": true
    }
  }
}
package.json
{
  "name": "sample-react-router-dom-verify",
  "version": "1.0.0",
  "private": true,
  "dependencies": {
    "react-router-dom": "6.30.4"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify react-router-dom.createMemoryRouter in pkg:npm/react-router-dom@6.30.4",
  "kind": "HOW",
  "packages": [
    "pkg:npm/react-router-dom@6.30.4"
  ],
  "symbols": [
    "createMemoryRouter"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "runtime": "node@22.23.2"
  }
}
src/index.js
const {
  createMemoryRouter,
  matchRoutes,
  generatePath,
  createSearchParams,
} = require("react-router-dom");

function buildMemoryRouter(routes, options = {}) {
  return createMemoryRouter(routes, {
    initialEntries: options.initialEntries || ["/"],
    initialIndex: options.initialIndex !== undefined ? options.initialIndex : 0,
  });
}

function matchUrlRoutes(routes, location) {
  return matchRoutes(routes, location);
}

function buildPath(pattern, params) {
  return generatePath(pattern, params);
}

function buildSearchParams(init) {
  return createSearchParams(init);
}

module.exports = {
  buildMemoryRouter,
  matchUrlRoutes,
  buildPath,
  buildSearchParams,
};
test/contract.js
const assert = require("node:assert");
const {
  createMemoryRouter,
  matchRoutes,
  generatePath,
  createSearchParams,
} = require("react-router-dom");
const {
  buildMemoryRouter,
  matchUrlRoutes,
  buildPath,
  buildSearchParams,
} = require("../src/index.js");

const routes = [
  {
    path: "/",
    id: "root",
    children: [
      {
        index: true,
        id: "home",
      },
      {
        path: "users/:userId",
        id: "user-detail",
      },
      {
        path: "settings",
        id: "settings",
      },
    ],
  },
];

// 1. assert createMemoryRouter creates in-memory router with initial entries and active state matches
const router = buildMemoryRouter(routes, {
  initialEntries: ["/users/42?tab=profile#section1"],
  initialIndex: 0,
});
assert(router && typeof router.navigate === "function", "router should be initialized with navigate function");
assert.strictEqual(router.state.location.pathname, "/users/42");
assert.strictEqual(router.state.location.search, "?tab=profile");
assert.strictEqual(router.state.location.hash, "#section1");
assert.strictEqual(router.state.matches.length, 2);
assert.strictEqual(router.state.matches[0].route.id, "root");
assert.strictEqual(router.state.matches[1].route.id, "user-detail");
assert.strictEqual(router.state.matches[1].params.userId, "42");

// 2. assert router.navigate updates the current location pathname and active matches
router.navigate("/settings");
assert.strictEqual(router.state.location.pathname, "/settings");
assert.strictEqual(router.state.matches.length, 2);
assert.strictEqual(router.state.matches[1].route.id, "settings");

// 3. assert matchRoutes matches route hierarchies against a pathname and extracts route params
const matches = matchUrlRoutes(routes, "/users/99");
assert(Array.isArray(matches), "matches should be an array");
assert.strictEqual(matches.length, 2);
assert.strictEqual(matches[0].route.id, "root");
assert.strictEqual(matches[1].route.id, "user-detail");
assert.strictEqual(matches[1].params.userId, "99");

const noMatches = matchUrlRoutes(routes, "/unknown/path");
assert.strictEqual(noMatches, null);

// 4. assert generatePath replaces path parameters in path patterns
const path = buildPath("/users/:userId/posts/:postId", {
  userId: "42",
  postId: "100",
});
assert.strictEqual(path, "/users/42/posts/100");

// 5. assert createSearchParams creates URLSearchParams from key-value pairs
const searchParams = buildSearchParams({ filter: "active", page: "2" });
assert.strictEqual(searchParams.get("filter"), "active");
assert.strictEqual(searchParams.get("page"), "2");
assert.strictEqual(searchParams.toString(), "filter=active&page=2");

console.log("PASS: react-router-dom createMemoryRouter contract assertions verified");

Origin Seeder

anonymous