Skip to content

feat: migrate from Next.js to Astro#12

Open
soorria wants to merge 15 commits into
mainfrom
astro-3
Open

feat: migrate from Next.js to Astro#12
soorria wants to merge 15 commits into
mainfrom
astro-3

Conversation

@soorria
Copy link
Copy Markdown
Owner

@soorria soorria commented Jan 31, 2026

Summary

Migrate soorria.com from Next.js 15.5.4 to Astro 5.x using a side-by-side approach:

  • Phase 1 (Complete): Project scaffolding & content collections
    • Move Next.js code to next-16/ directory
    • Initialize fresh Astro project in astro/ directory
    • Set up Content Collections with symlinked content
    • Configure React, MDX, Tailwind integrations

Migration Approach

The migration uses a side-by-side structure:

soorria.com/
├── next-16/      # Original Next.js code (preserved, runnable)
├── astro/        # New Astro project
└── thoughts/     # Migration docs

Both projects can run simultaneously:

  • Next.js: cd next-16 && pnpm dev (port 3000)
  • Astro: cd astro && pnpm dev (port 4321)

Remaining Phases

  • Phase 2: Layouts & Base Components
  • Phase 3: Static Pages
  • Phase 4: Content Collections & Dynamic Routes
  • Phase 5: Homepage & Interactive Features
  • Phase 6: API Routes & Feeds
  • Phase 7: Middleware & Advanced Routing
  • Phase 8: Vercel Configuration & Deployment
  • Phase 9: Flatten Structure & Cleanup

Related Documents

  • Research: thoughts/shared/research/2026-01-31-astro-migration-research.md
  • Plan: thoughts/shared/plans/2026-01-31-astro-migration.md

Test plan

  • Next.js still runs from next-16/
  • Astro dev server starts and builds
  • Content collections load blog/snippets/projects
  • Symlinks work for content and public assets

This is the first step in migrating from Next.js to Astro. All existing
Next.js code has been moved to the `next-16/` directory to allow:

- Running Next.js as a reference during migration
- Fresh Astro project initialization in `astro/` directory
- Side-by-side comparison of both implementations

The Next.js site remains fully functional from the next-16/ directory.

Also adds migration research and implementation plan documents.
Set up fresh Astro 5.17.1 project alongside Next.js for incremental migration:

- Initialize Astro with React, MDX, and Vercel integrations
- Configure Tailwind CSS 4 via @tailwindcss/vite
- Set up Content Collections for blog, snippets, and projects
- Symlink content from next-16/src/data and public assets
- Configure rehype/remark plugins for MDX processing
- Add vercel.json for dynamic redirects and caching headers
- Copy utility files needed by content components
- Create test page verifying content collections work

Structure:
- astro/        - New Astro project
- next-16/      - Original Next.js code (preserved)
- thoughts/     - Migration docs (at root)

Both projects can run simultaneously:
- Next.js: cd next-16 && pnpm dev (port 3000)
- Astro: cd astro && pnpm dev (port 4321)
Phase 2 of the Astro migration:
- Add Layout.astro and MainLayout.astro base layouts
- Copy and adapt React components (Header, Footer, SpinnyHomeLink, etc.)
- Remove Next.js dependencies (next/link, usePathname) from components
- Add icons, links, and constants
- Copy Tailwind config and global styles (globals.css, prose.css)
- Add MainLayout component
- Add Hero component and hero-patterns for landing pages
- Add PostLayout and ProseWrapper for content pages
Phase 3 of the Astro migration:
- Add 404 error page
- Add contact-success thank you page
- Add about page using misc content collection
- Add uses page using misc content collection
- Add misc collection to content.config.ts
- Fix CSS circular import issue in prose.css
- Add use-fullscreen, use-local-storage, use-temporary-state-react to
  exclusion list (missing explicit imports from ./components in MDX)
- Demo component already supports component prop for ReactDemo wrapper
Add explicit imports to MDX files that were missing them:
- blog/event-delegation: import BubblingDemo
- snippets/use-fullscreen: import Example
- snippets/use-local-storage: import Example, LOCALSTORAGE_KEY
- snippets/use-temporary-state-react: import Example

All blog posts now render in Astro. Only 4 snippets still excluded:
- create-previous-memo (SolidJS)
- safe-view-transition (window at module level)
- use-copy-react (JSX in Collapse summary)
- use-is-mouse-inactive-solid (SolidJS)
Changed summary prop type from string to ReactNode. The use-copy-react
snippet still fails due to Astro MDX JSX interop issues, so it remains
excluded along with 3 other snippets (2 SolidJS, 1 window at module level).
Comprehensive report covering:
- 4 excluded snippets with fix options
- Missing features (API routes, magic-sprinkles, comments, analytics)
- Missing redirects and sitemap
- Priority matrix and quick wins
- Testing checklist
Major additions:
- Add sitemap integration (@astrojs/sitemap)
- Add Plausible analytics proxy via vercel.json
- Add Giscus comments to blog and snippet pages
- Add SolidJS demo support via esm.sh dynamic loading
- Add curl-card API endpoint (/api/curl-card)
- Add JSON API for snippets (/api/snippets, /api/snippets/[slug])

Content fixes:
- Fix safe-view-transition: wrap window access in typeof check
- Fix use-copy-react: simplify Collapse summary to plain string

All 35 snippets and 13 blog posts now render successfully.
- Add magic-sprinkles interactive canvas animation
- Update MIGRATION_TODO.md to reflect completed status
- All 35 snippets and 13 blog posts now working
- All features implemented: sitemap, analytics, comments, APIs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants