--- title: "Vue.js vs Next.js: Modal Routing — A Side-by-Side Breakdown" author: "Heba Allah Hashim" published: "2026-08-14T09:07:02.763Z" updated: "2026-08-24T13:50:00.185Z" url: "https://zyvop.com/vue-js-vs-next-js-modal-routing-a-side-by-side-breakdown-pn0kq" canonical: "https://zyvop.com/vue-js-vs-next-js-modal-routing-a-side-by-side-breakdown-pn0kq" tags: ["webdev","Vue.js"] --- # Vue.js vs Next.js: Modal Routing — A Side-by-Side Breakdown ![Cover image]() Let's look at the breakdown of both frameworks side-by-side to understand the massive shift in mindset. * * * ## Project 1: The Vue.js Approach (Code-Driven Logic) ### Step 1: Initialize the Project ```bash npm create vite@latest vue-modal-app -- --template vue cd vue-modal-app npm install vue-router@4 ``` ### Step 2: Configure the Routing Paths (`src/router.js`) ```js import { createRouter, createWebHistory } from 'vue-router' import GalleryView from './views/GalleryView.vue' export const router = createRouter({ history: createWebHistory(), routes: [ { path: '/', component: GalleryView, children: [ { path: 'photo/:id', component: () => import('./components/PhotoModal.vue'), props: true } ] } ] }) ``` ### Step 3: Link the Router to the Application Update `src/main.js`: ```js import { createApp } from 'vue' import App from './App.vue' import { router } from './router' createApp(App).use(router).mount('#app') ``` Replace `src/App.vue`: ```vue ``` ### Step 4: Create the Gallery List Page (`src/views/GalleryView.vue`) ```vue ``` ### Step 5: Create the Popup Modal Component (`src/components/PhotoModal.vue`) ```vue ``` Run via `npm run dev` to view. * * * ## Project 2: The Next.js Approach (Folder-Driven Architecture) ### Step 1: Initialize the Project ```bash # Configuration flags: TypeScript (Yes), ESLint (No), src/ (No), App Router (Yes) npx create-next-app@latest next-modal-app cd next-modal-app ``` ### Step 2: Create the File Folders Manually create the exact folders matching the Hierarchy Map above directly inside your editor's file sidebar to prevent system escape errors. ### Step 3: Set up the Main Gallery Page (`app/gallery/page.tsx`) ```typescript import Link from 'next/link'; export default function GalleryPage() { return (

Next.js Photo Gallery

{['sunset', 'ocean', 'mountains'].map((photoId) => ( View {photoId} ))}
); } ``` ### Step 4: Configure the Layout Slots (`app/gallery/layout.tsx`) ```typescript export default function GalleryLayout({ children, modal }: { children: React.ReactNode; modal: React.ReactNode; }) { return (
{children} {modal}
); } ``` ### Step 5: Create the Slot Fallback (`app/gallery/@modal/default.tsx`) ```typescript export default function DefaultModal() { // Fixes the unmounted slot mismatch crash by returning a baseline null return null; } ``` ### Step 6: Create the Intercepted Popup View (`app/gallery/@modal/(.)photo/[id]/page.tsx`) ```typescript 'use client'; import { useRouter, useParams } from 'next/navigation'; export default function InterceptedPhotoPopup() { const router = useRouter(); const params = useParams(); return (

Next.js Intercepted Popup

📸 {params.id}

); } ``` ### Step 7: Create the Standalone Fallback Page (`app/gallery/photo/[id]/page.tsx`) ```typescript import Link from 'next/link'; interface PageProps { params: Promise<{ id: string }>; } export default async function StandalonePhotoPage({ params }: PageProps) { // Modern Next.js rule: params must be unwrapped asynchronously const { id } = await params; return (

Standalone Full-Screen View

🌌 {id.toUpperCase()}
← Back to Gallery List
); } ``` Run via `npm run dev` and navigate to `http://localhost:3000/gallery`.