URL Routing
URL structure and pathname parsing utilities
This page explains the URL routing structure used in ChatJS.
Route Types
| Route Pattern | Description |
|---|---|
/ |
Home page, draft chat (not yet persisted) |
/chat/:id |
Standalone chat page |
/share/:id |
Public shared chat page (read-only) |
/project/:projectId |
Project page, draft chat within project |
/project/:projectId/chat/:chatId |
Chat within a project |
Parsing Pathnames
Use parseChatIdFromPathname from @/providers/parse-chat-id-from-pathname to classify chat, project chat, shared chat, draft, and passthrough routes.
Related Hooks
useCurrentChatRoute()- Returns the parsed route for client components that need the active chat or project scopeuseDraftChatId()- Returns a client-generated draft id for writable home and project routes
See Next.js Chat Transition for how draft ids and runtime keys preserve state during first-message navigation.
See Projects for how project-scoped routes work.