Part of #352
Remove all Pages Router code after the App Router migration is complete.
Research
Files to Remove
Pages Directory (src/pages/):
pages/
├── _app.tsx # App wrapper with providers
├── _document.tsx # Document with Sentry/Plausible scripts
├── index.tsx # Home page
├── 404.tsx # Custom 404 page
├── docs.tsx # Documentation page
├── support.tsx # Support page
├── api-aspect.tsx # API Aspect page
├── settings/ # All settings pages
├── times-square/ # All Times Square pages
└── api/
└── dev/ # All mock API routes
Legacy Context:
src/contexts/AppConfigContext.tsx - Original Pages Router context
Legacy Loaders:
src/lib/config/loader.ts - loadAppConfig() function
src/lib/config/footerLoader.ts - Footer MDX loader
SWR Dependency:
- Remove SWR package after BroadcastBanner migration (Phase 6)
Dependencies to Check
Before removing, verify no code depends on:
useAppConfig() hook from AppConfigContext
loadAppConfig() function
- Pages Router specific utilities
- SWR hooks (after Phase 6 migration)
Configuration Changes
next.config.js:
- Remove any Pages Router specific configuration
- Update rewrites if needed
- Verify
transpilePackages still works
package.json:
- Remove SWR dependency
- May be able to remove other Pages Router specific dependencies
Proposed Design
Cleanup Checklist
- Verify all pages migrated - Each route has App Router equivalent
- Search for imports - Find any remaining imports of old modules
- Remove pages directory - Delete
src/pages/
- Remove legacy context - Delete or deprecate
AppConfigContext
- Clean up loaders - Remove or mark as deprecated
- Remove SWR - Delete SWR dependency from package.json
- Update documentation - Update any docs referencing old patterns
- Update tests - Remove or migrate tests for deleted code
Import Search Patterns
Search for these patterns to find remaining dependencies:
# AppConfigContext imports
grep -r "from.*AppConfigContext" src/
grep -r "useAppConfig" src/
# loadAppConfig imports
grep -r "loadAppConfig" src/
grep -r "from.*config/loader" src/
# Pages Router hooks
grep -r "from 'next/router'" src/
# getServerSideProps
grep -r "getServerSideProps" src/
# SWR imports
grep -r "from 'swr'" src/
grep -r "useSWR" src/
Deprecation vs Removal
Option A: Full Removal (Recommended)
- Delete all Pages Router code
- Removes maintenance burden
- Clean codebase
Option B: Deprecation
- Mark old code as deprecated
- Keep for reference
- More complexity
Final State
After cleanup:
src/
├── app/ # App Router pages and layouts
│ ├── layout.tsx
│ ├── page.tsx
│ ├── settings/
│ ├── times-square/
│ └── api/
│ └── dev/
├── components/ # Shared components (unchanged)
├── contexts/
│ └── rsc/ # RSC contexts only
│ └── ConfigProvider.tsx
├── lib/
│ ├── config/
│ │ └── rsc/ # RSC config only
│ ├── discovery/
│ │ └── rsc/
│ └── mdx/
│ └── rsc/
└── ...
Implementation Details
Step 1: Verify Migration Complete
Checklist before cleanup:
Step 2: Search for Remaining Imports
Run search commands to find any remaining dependencies on old code.
Step 3: Update Any Remaining Code
If components still import old patterns:
- Update to use RSC patterns
- Replace
useAppConfig() with useStaticConfig()
- Replace
loadAppConfig() with getStaticConfig()
Step 4: Remove Pages Directory
Step 5: Remove Legacy Context
File to remove: src/contexts/AppConfigContext.tsx
Or if keeping for backwards compatibility:
// src/contexts/AppConfigContext.tsx
/**
* @deprecated Use useStaticConfig() from @/contexts/rsc/ConfigProvider instead
*/
export { useStaticConfig as useAppConfig } from "./rsc/ConfigProvider";
Step 6: Remove Legacy Loaders
Files to remove or deprecate:
src/lib/config/loader.ts
src/lib/config/footerLoader.ts
Keep if needed for any scripts or tooling.
Step 7: Remove SWR Dependency
After verifying no SWR imports remain:
pnpm remove swr --filter squareone
Step 8: Update Configuration
next.config.js:
// Remove Pages Router specific config
// Verify App Router config is correct
Step 9: Clean Up Tests
- Remove tests for deleted code
- Update test imports
- Verify test suite passes
Step 10: Update Documentation
- Update CLAUDE.md with new patterns
- Update any developer documentation
- Remove references to
getServerSideProps
- Remove references to SWR
Testing Strategy
- Full regression test - All routes render correctly
- Build verification - Production build succeeds
- Type checking - No TypeScript errors
- Lint verification - No lint errors about missing imports
- E2E tests - All user flows work
Risk Mitigation
- Create backup branch before cleanup
- Run full test suite before and after
- Deploy to staging environment first
- Monitor for errors after production deploy
Acceptance Criteria
Post-Cleanup Verification
After deployment, verify:
- All pages load correctly
- Navigation works
- Authentication flows work
- Times Square features work
- Settings pages work
- Analytics (Plausible) tracking works
- Error tracking (Sentry) works
- Development mode with mocks works
- Broadcast banners display and refresh correctly
Part of #352
Remove all Pages Router code after the App Router migration is complete.
Research
Files to Remove
Pages Directory (
src/pages/):Legacy Context:
src/contexts/AppConfigContext.tsx- Original Pages Router contextLegacy Loaders:
src/lib/config/loader.ts-loadAppConfig()functionsrc/lib/config/footerLoader.ts- Footer MDX loaderSWR Dependency:
Dependencies to Check
Before removing, verify no code depends on:
useAppConfig()hook fromAppConfigContextloadAppConfig()functionConfiguration Changes
next.config.js:
transpilePackagesstill workspackage.json:
Proposed Design
Cleanup Checklist
src/pages/AppConfigContextImport Search Patterns
Search for these patterns to find remaining dependencies:
Deprecation vs Removal
Option A: Full Removal (Recommended)
Option B: Deprecation
Final State
After cleanup:
Implementation Details
Step 1: Verify Migration Complete
Checklist before cleanup:
/) works in App Router/docs) works/support) works/api-aspect) worksapp/not-found.tsx)app/error.tsx,app/global-error.tsx)Step 2: Search for Remaining Imports
Run search commands to find any remaining dependencies on old code.
Step 3: Update Any Remaining Code
If components still import old patterns:
useAppConfig()withuseStaticConfig()loadAppConfig()withgetStaticConfig()Step 4: Remove Pages Directory
Step 5: Remove Legacy Context
File to remove:
src/contexts/AppConfigContext.tsxOr if keeping for backwards compatibility:
Step 6: Remove Legacy Loaders
Files to remove or deprecate:
src/lib/config/loader.tssrc/lib/config/footerLoader.tsKeep if needed for any scripts or tooling.
Step 7: Remove SWR Dependency
After verifying no SWR imports remain:
Step 8: Update Configuration
next.config.js:
Step 9: Clean Up Tests
Step 10: Update Documentation
getServerSidePropsTesting Strategy
Risk Mitigation
Acceptance Criteria
src/pages/directory deleteduseAppConfig()from old contextloadAppConfig()next/router(usenext/navigation)getServerSidePropsexportsswrPost-Cleanup Verification
After deployment, verify: