MCPcopy Index your code
hub / github.com/ProNextJS/declarative-routing

github.com/ProNextJS/declarative-routing @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
202 symbols 688 edges 167 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Declarative Routes

declarative-routing sets up an optional declarative routing system for React or QwikCity projects. For NextJS, it maintains a global list of both pages and API routes and provides components and functions to easily navigate to pages, or make API requests.

What are Declarative Routes?

Typesafe routing is a way to ensure that your routes are structured properly; the parameters in the URL are correct and a route handler exists for that route. Declarative routing goes to the next step and ensures that your link is going to the correct route.

With typesafe routing you still have to deal with urls; <Link to={`/product/${product.id}`}>Product</Link>. With declarative routing you can use a component that is typed to the route, and that will generate the correct URL for you. <ProductDetail.Link productId={product.id}>Product</ProductDetail.Link>. Later on, if the route changes, or the parameters change, the ProductDetail.Link component will be updated to reflect that everwhere it is used in your application.

Installation

For NextJS projects follow the NextJS installation instructions.

For React Router projects follow the React Router installation instructions.

For QwikCity projects follow the QwikCity installation instructions.

Credit where credit is due

This system is based on the work in Fix Next.JS Routing To Have Full Type-Safety. However the original article had a significantly different interface and didn't cover API routes at all.

Extension points exported contracts — how you extend this code

InputProps (Interface)
(no doc)
examples/nextjs/finished/src/components/ui/input.tsx
InputProps (Interface)
(no doc)
examples/react-router/finished/src/components/ui/input.tsx
InputProps (Interface)
(no doc)
examples/nextjs/starter/src/components/ui/input.tsx
InputProps (Interface)
(no doc)
examples/react-router/starter/src/components/ui/input.tsx

Core symbols most depended-on inside this repo

getConfig
called by 14
src/config.ts
buildFileFromTemplate
called by 11
src/template.ts
createRouteBuilder
called by 5
assets/nextjs/makeRoute.tsx
addPackages
called by 5
src/shared/utils.ts
createRouteBuilder
called by 5
examples/nextjs/finished/src/routes/makeRoute.tsx
routeBuilder
called by 4
assets/react-router/makeRoute.tsx
absoluteFilePath
called by 4
src/config.ts
buildStringFromTemplate
called by 4
src/template.ts

Shape

Function 198
Interface 4

Languages

TypeScript100%

Modules by API surface

examples/nextjs/finished/src/routes/utils.ts11 symbols
assets/shared/utils.ts11 symbols
src/shared/build-tools.ts10 symbols
src/shared/utils.ts8 symbols
examples/nextjs/finished/src/routes/makeRoute.tsx8 symbols
assets/nextjs/makeRoute.tsx8 symbols
src/shared/watch.ts7 symbols
examples/react-router/finished/src/routes/makeRoute.tsx7 symbols
assets/react-router/makeRoute.tsx7 symbols
src/config.ts4 symbols
examples/react-router/starter/src/pokemon.ts4 symbols
examples/react-router/finished/src/pokemon.ts4 symbols

For agents

$ claude mcp add declarative-routing \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact