Skip to content

Migrate runtime to Next.js App Router and introduce framework-agnostic routing boundary#458

Draft
jimmyandrade with Copilot wants to merge 4 commits into
mainfrom
copilot/migrate-site-to-nextjs
Draft

Migrate runtime to Next.js App Router and introduce framework-agnostic routing boundary#458
jimmyandrade with Copilot wants to merge 4 commits into
mainfrom
copilot/migrate-site-to-nextjs

Conversation

Copilot AI commented Jul 16, 2026

Copy link
Copy Markdown

This PR starts the Gatsby→Next migration by moving the site runtime to Next.js 16 App Router while preserving existing templates/content. It also introduces a framework boundary so core UI/page composition is no longer directly coupled to Gatsby, enabling future portability to Next/Remix-style runtimes.

  • Runtime migration (App Router)

    • Added src/app route tree for main paths (/, /ajuda, /consultar, /denunciar, /privacidade, /sobre, /termos) plus not-found.
    • Replaced legacy route entrypoints by removing src/pages to avoid App/Pages route conflicts.
    • Added Next metadata routes: manifest, robots, sitemap.
  • Framework-agnostic boundary

    • Introduced src/framework/router.js with shared primitives (RouterLink, navigateTo, getPath).
    • Refactored templates/components that imported Gatsby navigation directly (Footer, NavigationDrawer, HomeCheckParkingForm, templates/index, templates/about) to use the framework adapter.
  • Metadata decoupling

    • Updated useSiteMetadata to read from shared config (config/siteMetadata) instead of Gatsby GraphQL/static query APIs.
    • Kept SEO/template behavior intact while removing hard dependency on Gatsby data layer for metadata lookup.
  • Next bootstrapping + compatibility bridge

    • Added next.config.js and switched package scripts (develop, build, serve) to Next runtime.
    • Added a Gatsby shim (src/framework/gatsby-shim.js) for transitional compatibility with legacy imports from shared dependencies during migration.
  • Query handling in App Router

    • /consultar now reads query string via useSearchParams with Suspense-safe rendering and preserves existing template contract (search string).
// src/framework/router.js
export const RouterLink = React.forwardRef(({ to, href, ...props }, ref) => (
  <a href={href ?? to} ref={ref} {...props} />
))

export const getPath = (path) => path
export const navigateTo = (path) => {
  if (typeof window !== "undefined") window.location.assign(path)
}
  • Docs alignment
    • Updated README to reflect Next App Router structure and framework-agnostic template intent.
    • Added troubleshooting entries for restricted-network Cypress install failures and App-vs-Pages route conflicts.

Copilot AI linked an issue Jul 16, 2026 that may be closed by this pull request
19 tasks
Copilot AI changed the title [WIP] Migrate site from Gatsby to Next.js with App Router Migrate runtime to Next.js App Router and introduce framework-agnostic routing boundary Jul 16, 2026
Copilot AI requested a review from jimmyandrade July 16, 2026 18:17
@jimmyandrade
jimmyandrade requested a review from Copilot July 17, 2026 18:46
@jimmyandrade jimmyandrade added the enhancement New feature or request label Jul 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Migrates the site runtime from Gatsby to Next.js App Router while keeping the existing page templates, and introduces a thin routing adapter (src/framework/router.js) to decouple UI/templates from any specific routing framework.

Changes:

  • Adds a new src/app App Router route tree (including metadata routes like manifest, robots, sitemap) and removes legacy src/pages entrypoints to avoid route conflicts.
  • Refactors templates/components away from Gatsby navigation APIs to a framework adapter (RouterLink, navigateTo, getPath) and adds a Gatsby shim for transitional compatibility.
  • Updates metadata sourcing to shared config (config/siteMetadata) and aligns docs/troubleshooting with the new runtime.

Reviewed changes

Copilot reviewed 33 out of 36 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
TROUBLESHOOTING.md Documents Cypress install failures in restricted networks and Next App/Pages route conflicts.
src/templates/index.js Switches template links/buttons to use RouterLink instead of Gatsby Link.
src/templates/check.js Makes query parsing compatible with App Router by accepting a search prop.
src/templates/about.js Switches CTA button to RouterLink.
src/pages/pages.test.js Removes Gatsby pages export tests (Pages Router removed).
src/pages/index.js Removes Gatsby Pages Router entrypoint for /.
src/pages/consultar/index.js Removes Gatsby Pages Router entrypoint for /consultar.
src/hooks/useSiteMetadata.js Replaces Gatsby static query with shared config/siteMetadata.
src/framework/router.test.js Adds tests for the new routing boundary primitives.
src/framework/router.js Introduces framework-agnostic RouterLink, getPath, navigateTo.
src/framework/gatsby-shim.js Adds shim module for gatsby imports during migration.
src/containers/RecoilProviderWrapper/index.js Adds a RecoilProvider for Next App Router layout usage.
src/containers/HomeCheckParkingForm/index.js Refactors navigation/path prefix handling to the framework router adapter.
src/components/NavigationDrawer/index.js Updates drawer navigation items to use RouterLink.
src/components/Footer/index.test.js Updates test description to be framework-agnostic.
src/components/Footer/index.js Updates footer links to use RouterLink.
src/app/termos/page.js Adds App Router page for /termos.
src/app/sobre/page.js Adds App Router page for /sobre.
src/app/sitemap.js Adds Next metadata route for sitemap generation.
src/app/robots.js Adds Next metadata route for robots.txt generation.
src/app/privacidade/page.js Adds App Router page for /privacidade.
src/app/page.js Adds App Router home page entrypoint.
src/app/not-found.js Adds App Router not-found entrypoint.
src/app/manifest.js Adds Next metadata route for web app manifest.
src/app/layout.js Adds root layout and Next metadata from shared site metadata.
src/app/globals.css Adds basic global CSS for Next layout.
src/app/denunciar/page.js Adds App Router page for /denunciar.
src/app/consultar/page.js Adds App Router page for /consultar with Suspense-safe query string handling.
src/app/ClientLayout.js Adds a client layout wrapper to provide Recoil + existing Layout.
src/app/ajuda/page.js Adds App Router page for /ajuda.
README.md Updates documentation to reflect Next.js App Router structure and install guidance.
package.json Switches scripts to Next and upgrades React/ReactDOM; adds Next dependency.
package-lock.json Updates lockfile for Next + React 18 dependency graph.
next.config.js Adds Next config and aliases gatsby to the migration shim.
config/siteMetadata/index.js Adjusts env var names for Next and removes Gatsby-specific dotenv bootstrap.
.gitignore Ignores .next/ build output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread package.json
Comment on lines +81 to +85
"next": "16.2.10",
"prop-types": "15.7.2",
"query-string": "6.14.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"react": "18.3.1",
"react-dom": "18.3.1",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate site from Gatsby to Next.js (App Router)

3 participants