Weird useParams() behavior

Hello,

I put my website on vercel some months ago for my discord bot’s dashboard. Everything was working fine and well. Recently I updated it again with NextJS 16 and all new dependencies and now, useParams() returns weird values instead of the proper ones. This issue does not happen on local testing with next dev and next start. I have a page with a [id] param and the website on Vercel gives me: {id: '%%drp:id:c2ee75dd83235%%'} instead of 668213441453883394 from this link https://infinium.deoptimize.dev/dashboard/668213441453883394.

1 Like

Hi @nikosszzz, welcome to the Vercel Community!

Can you please share your public repo or a minimal reproducible example. That will let us all work together from the same code to figure out what’s going wrong.

this is happening to me as well, nextjs 16 is casuing this problem.

Note: it doesn’t happen on localhost.. only in production

console.log: pushing to edit campaign deb13da1-795d-41e0-ac66-84c2bf361ef1 (app/campaigns/page.tsx)
console.log: edit campaign page: %%drp:id:f386f06786ce7%% **(app/campaigns/[id]/page.tsx)
**
%%drp:id:f386f06786ce7%% should be deb13da1-795d-41e0-ac66-84c2bf361ef1, what the hell is %%drp:id:f386f06786ce7%%

1 Like

The process is just this really:

  • I have a /dashboard route (app/dashboard/page.tsx). This page shows you the servers you have access to via my discord bot.
  • Clicking on a server takes you to a route with a [id] param (app/dashboard/[id]/page.tsx). Within that page, I do const { id: guildID } = useParams<{ id: string }>();.

Now, normally, guildID should be normal (e.g. 668213441453883394) representing a discord guild ID. Instead, it returns this weird value %%drp:id:c2ee75dd83235%%. For some reason it has gone away after some hours of the deployment being up, without touching anything but I would assume the issue would return again temporarily on my next deployment.

Hi @kga-6 and @nikosszzz, thanks for elaborating more on this.

I’m unable to recreate this on a fresh Next.js ("next": "16.0.1") installation:

Can you share the exact Next.js version, so I can recreate it and then open a Next.js issue? (I don’t see one open for it right now)

Hi @anshumanb, your screenshot appears to be from localhost rather than a domain. We’re experiencing the same behavior - it works fine on localhost but fails when deployed to production.

my version is: “next”: “^16.0.1”

2 Likes

Hi @kga-6, thanks for pointing that out. Here is the production deployment: Create Next App

Can you try deploying the app in a fresh Vercel project and see if that fixes it? I doubt it’s a Next.js issue because useParams has been stable for years and there’s no other reports on the Next.js repo. It may be a transient glitch.

My issue seems to have gone away for the most part. I rarely get it as of now, having done no changes to my website besides some small UI-related things in my new deployments. It seems to be happening either randomly or for a good 1-2 hours for me.

Hi @hqmank-3091, welcome to the Vercel Community!

Can you share your public repo where I can reproduce this?

i disabled cacheComponents and now its working fine. @hqmank-3091 @nikosszzz try setting cacheComponents to false in next.config.js

it fixed the problem for me

2 Likes

Hi Kevin Thank you very much! @kga-6

2 Likes

I’m unable to recreate this even with cacheComponents: true

'use client';

import { useParams } from 'next/navigation';
import { useEffect } from 'react';

export function StudioWorkspaceProvider({ children }) {
  const params = useParams<{ workspaceAlias?: string }>();
  
  useEffect(() => {
    console.log('workspaceAlias:', params.workspaceAlias);
    // Expected: "cmiv5jlg10000dzibtoqkmqvh"
    // Actual (sometimes): "%%drp:workspaceAlias:dd80498a69064%%"
  }, [params.workspaceAlias]);

  return <>{children}</>;
}

Same problem occurs. useParams() returns build-time placeholder value %%drp:...%% in client component during production build

next@16.0.8, cacheComponents: true


Update: I found that the issue was resolved by setting prefetch={false} on the Link component. It seems the problem occurs when is combined with dynamicIO. During prefetching, dynamic params are replaced with placeholders, and these placeholder values leak into useParams() in client components.

%%drp:paramName:hash%% placeholder appears to be used internally by Next.js during PPR (Partial Prerendering) to represent dynamic route parameters that are unknown at build/prefetch time.

Expected flow:

  1. Prefetch generates static shell with placeholders
  2. On navigation, placeholders are replaced with actual values
  3. Client components receive real params via useParams()

Actual flow (bug):

  1. Prefetch generates static shell with placeholders
  2. Client component hydrates before placeholder replacement
  3. useParams() returns raw placeholder string %%drp:...%%

This suggests a race condition or incorrect hydration order when dynamicIO is enabled with Link prefetching.