How AI is powering better personalization in e-commerce [with Vercel]. Sign up now

Dynamic links showing "An unexpected error has occurred" after Now deployment

12 repliesLast updated: Nov 29, 2025

Hello. I followed the Next.js tutorial, deployed on Now, the dynamic links renders
An unexpected error has occurred.
AI Update

Based on your description, you're encountering an "unexpected error" with dynamic links after deploying your Next.js app with Sanity to Vercel. This is almost certainly due to a breaking change in Next.js 15 regarding dynamic route parameters.

The Problem

In Next.js 15, the params prop in dynamic route pages is now a Promise instead of a plain object. If you're accessing params.slug (or any param) directly without awaiting it, your page will crash in production.

The Solution

You need to await the params before accessing any properties. Here's how to fix it:

❌ Old way (causes error):

export default function Page({ params }: { params: { slug: string } }) {
  const { slug } = params; // This breaks in Next.js 15
  // ...
}

✅ New way (correct):

export default async function Page({
  params,
}: {
  params: Promise<{ slug: string }>;
}) {
  const { slug } = await params; // Await the params first
  // ...
}

Complete Working Example

Here's a full example with Sanity data fetching:

import { defineQuery } from "next-sanity";
import { client } from "@/sanity/client";

const query = defineQuery(
  `*[_type == "page" && slug.current == $slug][0]{title, content}`
);

export default async function Page({
  params,
}: {
  params: Promise<{ slug: string }>;
}) {
  const { slug } = await params;

  const data = await client.fetch(query, { slug });

  return (
    <div>
      <h1>{data.title}</h1>
      <div>{data.content}</div>
    </div>
  );
}

What Changed:

This applies to all dynamic routes in your app:

After updating your dynamic route files with these changes, redeploy to Vercel and your pages should work correctly. This is documented in the Next.js App Router guide where it notes that Next.js 15 requires awaiting route params.

Show original thread
12 replies

Was this answer helpful?

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Related contributions