Docs/Routing & Data/Routing

Routing & Data

Routing

Routing — Routing & Data documentation for BCP Framework.

Last updated: 2026-08-29T01:11:41

Routing

BCP Framework uses the app/ directory as the routing source of truth.

Static routes

text
app/page.tsx        /
app/about/page.tsx  /about

Dynamic segments

text
app/users/[id]/page.tsx

A request to /users/15 receives:

TypeScript
{
    params: {
        id: "15",
    },
}

Catch-all segments

text
app/docs/[...slug]/page.tsx

/docs/guides/install receives:

TypeScript
params.slug // ["guides", "install"]

A required catch-all must consume at least one URL segment.

Optional catch-all segments

text
app/catalog/[[...slug]]/page.tsx

Both /catalog and /catalog/hardware/keyboards match. The base route receives slug === undefined; nested paths receive a string array.

Route groups

text
app/(admin)/layout.tsx
app/(admin)/settings/page.tsx

The public URL is /settings. The (admin) segment participates in filesystem layout composition but is removed from the public pathname.

Priority

When multiple patterns can match, BCP prefers:

text
static
→ dynamic
→ catch-all
→ optional catch-all

Route discovery rejects ambiguous patterns and duplicate public paths instead of selecting a route nondeterministically.

Layouts

Layouts are inherited from the app root through nested directories and route groups. Client navigation preserves compatible layout identities so layout state can survive page changes.

Special files

BCP recognizes route-adjacent special files including:

text
layout.tsx
loading.tsx
error.tsx
not-found.tsx

Navigation

Use Link, navigate or useRouter from bcp for client navigation.

TypeScript
import {
    Link,
} from "bcp";

export default function Page() {
    return (
        <Link href="/about">
            About
        </Link>
    );
}