Routing Strategy
Slugs as Labels, IDs as Truth.
PRID: 1004
VERIFIED
1 min read
🧩 Routing: Slugs as Labels, IDs as Truth
In Instant Ship™, we have resolved the conflict between Named Parameters and Splats by introducing the Database Discovery Layer with ID-First Priority.
1. The "Slug is a Property" Mindset
We no longer treat the route parameter as the content source. Instead:
- The URL contains a Slug (User Friendly).
- The Link State contains the ID (System Friendly).
- The Page prioritizes the ID to fetch data instantly.
2. Strategic Benefits
- Infinite Nesting: Since we query the database for the path/id, it doesn't matter if there are 2 segments or 20.
- Dynamic Permalinks: You can change the slug of an article (e.g., from
old-guidetonew-guide) without losing the article's identity, as the ID remains constant. - Proxy Resilience: Even if the AI Studio Sandbox adds
.htmlto your URL, the ID passed in state remains pure.
3. Final Architecture Choice
- Docs: Use
[...slug]to capture everything. - Blogs: Use
$slugfor flat structure. - Protocol: Both MUST implement the
location.state.pridcheck before parsing the URL.
Key Lesson: Stop trying to parse structure from strings. Query structure from data using IDs.