Axon 911 Frontend DocsAxon 911 Frontend Docs
Axon 911 Frontend Docs
    Loading navigation…
U
User
Switch to light mode
  1. Working On Features
  2. Your First Page

Your First Page

Creating pages with routing and data fetching.

Quick Reference
Vite apps (dispatch, responder, caller):
  • Use React Router for routing
  • Client-side rendering only
  • The page makes one Apollo useQuery call; each component below it reads its own fragment
Next.js apps (docs, beacon):
  • File-based routing in app/ directory
  • Server Components for data fetching
  • Client Components for interactivity
Vite: Creating a Page
1. Add Route
2. Create the Page (the Query Root)
The page owns the request, so it is the query root: the only component on the screen that calls useQuery. It selects id on each incident, which Apollo needs to key the list and find the entity again, and spreads the fragment of the component it renders.
The query doesn't list title, status or priority. Those fields belong to the list item, which you write in the next step.
3. Give the List Item Its Own Fragment
IncidentListItem declares the fields it renders in a fragment named Component_prop, in a fragments.graphql next to it. Run pnpm codegen after you save the file.
The component takes a FragmentType prop, not the incident object, and opens it with useFragment. useFragment reads from the cache and makes no request. Always pass fragmentName: it keeps working when someone later adds a ...Child spread to the fragment.
With data masking on, the page can't read incident.title: it is a type error, and undefined at runtime. If the list item later needs another field, you add it to the fragment and nothing else changes. See GraphQL Fragments for the rules. To test IncidentListItem on its own, see Testing a Fragment-Owning Component on Its Own.
4. Access Route Params
The details page is its own route, so it is its own query root and selects the fields it shows directly.
Both queries sit in the pages folder's queries.graphql. If the details page grows child components, each one gets its own fragment, exactly as IncidentListItem did.
Next.js: Creating a Page
1. Create File in app/ Directory
2. Dynamic Routes
3. Client Components
For interactivity, use Client Components:
Navigation
Vite: React Router Link
Next.js: Link Component
Layouts
Vite: Layout Component
Next.js: layout.tsx
Data Fetching Patterns
Vite: Apollo Client
The page keeps the query and the mutation. IncidentListItem still takes its data as a FragmentType and reads it with useFragment. The onUpdate callback is a plain prop that you add to the component's props next to incident.
Next.js: Server Components
Styling Pages
Use Box props or co-located SCSS:
Error Boundaries
Wrap pages in error boundaries:
Related Documentation
  • Making a Feature - Code splitting and dynamic imports
  • Component Patterns - Component organization
  • GraphQL Operations - Data fetching
  • GraphQL Fragments - Component-owned fragments and data masking
  • Styling - SCSS and BEM patterns
Reference Files
For more detailed technical guidance, see these reference files:
  • AGENTS.md - Project structure and tech stack
  • react-best-practices SKILL.md - Framework-specific patterns
Previous
Working on features / Component Patterns
Next
Working on features / Making a Feature
On this page
Quick Reference
Vite: Creating a Page
1. Add Route
2. Create the Page (the Query Root)
3. Give the List Item Its Own Fragment
4. Access Route Params
Next.js: Creating a Page
1. Create File in app/ Directory
2. Dynamic Routes
3. Client Components
Navigation
Vite: React Router Link
Next.js: Link Component
Layouts
Vite: Layout Component
Next.js: layout.tsx
Data Fetching Patterns
Vite: Apollo Client
Next.js: Server Components
Styling Pages
Error Boundaries
Related Documentation
Reference Files