Demo, all content is generated
Question

ChatGPT keeps giving me pages router code when I'm on the app router

Open · 544 views · asked by rhys_m · edited

Every answer has getServerSideProps or pages/api/... in it. My project is Next 15 with the app/ folder. I say "I'm using app router" and it adapts, then two answers later it's back.

What I’ve tried

Put 'Next.js 15 app router' at the start of every message. Helps a bit.

Comment
Are you using a Project or custom instructions, or just normal chats? mei_lin · edited

3 answers

mei_lin · edited

It's biased toward the older style because there's far more of that code on the internet. Tell it once in a place it keeps:

  • Custom instructions / a Project with instructions: "Stack: Next.js 15 App Router, React 19, TypeScript, Supabase via @supabase/ssr. Never use pages/, getServerSideProps, or API routes unless I ask. Prefer Server Components and Server Actions."
  • Upload your package.json to the project so versions are in front of it.
Comment
bytebarista · edited

And when an answer has pages/ in it, don't fix it in the conversation, regenerate or start a new chat. Once there's old-style code in the context, it keeps copying from itself.

Comment
Project with instructions + package.json is much better. Still slips once in a while. rhys_m · edited
jonas_k · edited

When it matters, paste the relevant page of the official docs into the chat. It'll follow current docs in front of it over old habits from training.

Comment