r/nextjs • • 23h ago

Weekly Showoff Weekly Showoff Thread! Share what you've created with Next.js or for the community in this thread only!

3 Upvotes

Whether you've completed a small side project, launched a major application or built something else for the community. Share it here with us.


r/nextjs • • 3h ago

Question about the Workers free plan

Thumbnail
reddit.com
1 Upvotes

r/nextjs • • 8h ago

Domain driven design

2 Upvotes

Hi all!

I'm building an app with next.js and payload.

This application is growing and I would go for DDD.

Any suggestions on project structure?

I'm eager to read any wise advice.


r/nextjs • • 1d ago

Tomorrow is Black Friday and I don't trust our ISR pages. What are you checking on a headless store this week?

6 Upvotes

my stack is next.js app router on vercel, storefront api for products and cart.

last year our sale prices went live at midnight but the PDPs were static, so for like 40 min the page showed $89 and the cart showed $59. some people were happy about it lol but most thought the site was broken and leave

this year I moved to on demand revalidation, revalidateTag off the products/update webhook. it worked fine in testing but testing isn't midnight on black friday. if one of those webhooks is late or just never shows up that page stays wrong until something else touches it

I do have a dotcom monitor check running add to cart and checkout every 5 min but it's one test product and it doesn't look at the price on the page, so it wouldn't have caught last year's problem either

plan right now is to setup a script that starts at 12:05 and runs every 10 min. it pulls the 15ish sale PDPs, compares the html price to the storefront api and if they don't match it calls revalidateTag and slacks me. is that overkill? the only other option i can think of is purging everything at midnight and taking the cold starts, which during the busiest hour of the year seems worse

what else should I be looking at? feels like I'm missing something obvious


r/nextjs • • 1d ago

Contentful

2 Upvotes

Are there any good resources to use for learning contentful.


r/nextjs • • 2d ago

How do you decide between SSR, SSG, ISR and CSR in real-world Next.js projects?

Post image
10 Upvotes

I've been exploring different rendering strategies in Next.js, and one thing I've noticed is that choosing the right approach depends heavily on the type of application.

For example:

  • SSG seems ideal for blogs and documentation.
  • SSR makes sense for personalized and frequently changing content.
  • ISR is useful for content-heavy websites where rebuilding everything isn't practical.
  • CSR works well for interactive dashboards and application interfaces.

But in real-world applications, these approaches can overlap.

I'm curious about how other developers approach this.

  1. Do you usually combine multiple rendering strategies in one application?
  2. How do you decide when a page should use server-side data fetching?
  3. Have you experienced performance issues from choosing the wrong rendering strategy?

Interested in hearing practical experiences rather than just theoretical comparisons.


r/nextjs • • 3d ago

How do you decide when a query deserves its own endpoint?

35 Upvotes

In a Next.js app with Supabase I can fetch data in a Server Component, use a Server Action for a mutation or introduce a Route Handler when I need an endpoint. I keep changing my mind about the boundaries. What rule has held up for you as an app grows?


r/nextjs • • 3d ago

Our cart badge went 1, 2, 1 on one tap: TanStack Query keeps a mutation pending through onSuccess

0 Upvotes

We've been reworking the cart of a client's Next.js 16 food-ordering storefront, as design concepts on a staging branch. None of it is in production. Before the rework the add button waited for the server. With Slow 4G emulation that basket POST took 580-1220 ms, though the API itself answers an add in 10-18 ms. After the first add the page then fetched the whole basket again.

On the branch every basket write is a TanStack Query mutation. They all share one mutation scope, so they run one after another and an older answer can't land on top of a newer one. Each answer goes into the cache with setQueryData before the basket id cookie changes, and with a 10-second staleTime the query on the new key takes that basket as fresh. No second GET.

The cart badge adds pieces sent and not yet answered, which it reads with useMutationState filtered to status: "pending". Added lines and every total still come from the server's answer. Piece counts are optimistic; money never is.

The add buttons now react in their onSubmit, as soon as the request goes out. In one variant that took the visible response to a tap from 587-626 ms to 5-28 ms. That was a dev build on localhost, as is the trace below. We haven't measured a production build.

Then we put a DOM MutationObserver on the badge and did a first add to an empty cart on Slow 4G:

""  -> "1"   at 36 ms
"1" -> "2"   at 834 ms
"2" -> "1"   at 865 ms

By 834 ms the answer was in the cache and the new line was counted. The add was still pending, though. TanStack keeps a mutation pending until its onSuccess and onSettled have run, so for those 31 ms the same piece was counted twice: once in the cached lines, once as a pending add.

The fix is a marker per add, kept in the mutation context:

onMutate: () => ({ answered: false }),
onSuccess: (basket, _variants, context) => {
  if (context) context.answered = true;
  qc.setQueryData(basketKey(basket.encoded_id), basket);
  setBasketId(basket.encoded_id);
},

The badge skips answered adds. It reads the flag at render, not inside useMutationState's select, because that select only re-runs on mutation cache events and flipping a field on the context object isn't one. What re-renders the badge is the setQueryData call, through the basket query.

The trace above is from before the fix. We haven't taken a new one, and no test covers it yet.

If your badge sums cached lines and pending mutations, watch it during a first add on a throttled network and see whether it ever reads 2.


r/nextjs • • 4d ago

Server Actions vs Route Handlers in the Next.js App Router: how do you decide which to use for mutations?

15 Upvotes

I use Server Actions for mutations from my own UI (forms, buttons) and Route Handlers for webhooks, third-party calls or a possible mobile app later. I re-check auth inside every action instead of relying only on middleware.

Does this split hold up in production for you, and have Server Actions caused problems beyond simple forms?


r/nextjs • • 4d ago Bravo

What is the best headless CMS for Vercel and NextJS projects optimized for SEO and AI Visiblity?

29 Upvotes

'm building a new marketing site and blog on Next.js, hosted on Vercel, and I'm stuck picking a headless CMS. I need editors to control meta titles, descriptions, canonicals and OG images per page, manage schema like FAQ and Article without touching code, and publish quickly with ISR or on-demand revalidation.

I've looked at Sanity, Contentful, Payload, Storyblok and Hygraph. Sanity looks flexible but needs a lot of setup, Contentful gets expensive fast, and Payload is interesting since it runs inside Next.js, but I'm not sure how well it works for a non-technical content team.

The part I can't figure out is AI visibility. Does the CMS choice actually affect whether ChatGPT, Perplexity or Google's AI Overviews cite your content, or is it all about the writing, schema and server rendering? If you run Next.js on Vercel in production, which CMS did you pick and would you choose it again if SEO and AI search traffic were your main goals?


r/nextjs • • 5d ago

Anyone moved from Firebase to Supabase on a Next js app?

20 Upvotes

Anyone switched from Firebase to Supabase on a Next.js app?

I'm pretty much done with Firebase and Supabase keeps coming up as the replacement. I'd rather hear from people who've actually used it with Next than read another comparison blog post

How does auth work with server components and middleware? Was moving the data over painful? And if you looked at Supabase and went with something else, what did you pick


r/nextjs • • 5d ago

Agentic features in Next.js: where the agent should live and how events reach the browser

0 Upvotes

Adding an agent to a Next.js app raises a few architecture questions that "call the LLM from a route handler" doesn't answer once the agent does real work:

1. Keep the agent as its own TypeScript service. Agent runs can be long, call several tools and wait on a human. That doesn't fit request-scoped handlers with execution time limits. A separate agent service (e.g. built with Mastra) that your app talks to keeps runs alive independently of any single request.

2. Stream events, not just text. The browser needs more than tokens: run started, tool call started and finished, state changed, waiting for approval, run finished or errored. A typed event stream (this is what the AG-UI protocol standardises) lets your components react to each event instead of parsing prose.

3. Sync state both ways. If the agent updates data the page shows, send state snapshots and small deltas rather than re-fetching everything. The user and the agent should never disagree about what's on screen.

4. Make cancellation travel end to end. Closing a stream in the browser isn't the same as stopping a run. Cancellation should reach the agent service, and the UI should show a definite "stopped" state.

5. Put guardrails at the boundary. Validate tool arguments against a schema, time out slow steps, and require explicit approval before anything consequential. Your app is the last place a human can say no.

How are you structuring this today: agents inside route handlers, or as a separate service?

(This comes from a hands-on workshop Rainer Hahnekamp and Murat Sari, co-maintainers of CopilotKit's Angular integration, are running on Saturday, using CopilotKit, AG-UI and Mastra.)


r/nextjs • • 6d ago

Solo technical founder running a startup, looking for an optimal tech setup

Thumbnail reddit.com
0 Upvotes

r/nextjs • • 6d ago

Solo technical founder running a startup, looking for an optimal tech setup

Thumbnail reddit.com
0 Upvotes

r/nextjs • • 7d ago

I'm getting fake signups on my side project. How to handle them?

14 Upvotes

I have a small project. I'm seeing fake signups with throwaway emails and bursts of accounts within a few minutes.

What do you use for this?

- A CAPTCHA? Which one?

- A list of throwaway email domains, or an API?

- Rate limits per IP or per device?

- Per-user caps on anything that costs you money (AI calls, emails, SMS)?

How do you avoid blocking real users who use a VPN or a private relay email? That's my main worry. I'll share what I end up with.


r/nextjs • • 6d ago

Alguém aqui já desenvolveu uma plataforma robusta de estudos usando Next.js + Supabase + Vercel?

0 Upvotes

Estou desenvolvendo uma plataforma de estudos focada em preparação para Residência Médica, utilizando Next.js, Supabase, Vercel, VS Code e Claude AI como ferramentas principais.

A ideia é construir um banco de questões estruturado, com milhares de questões, filtros por especialidade, instituição, banca, área médica e assunto, além de um sistema inteligente de revisão espaçada, que organize automaticamente as revisões de acordo com o desempenho e as dificuldades do usuário.

Estou investindo em uma solução mais personalizada, que vá além dos modelos tradicionais de plataformas de questões.

Gostaria de ouvir experiências de quem já desenvolveu e mantém projetos com uma arquitetura semelhante, especialmente em relação aos seguintes pontos:

  • Supabase: como ele se comporta com bancos de dados grandes, milhares de usuários simultâneos e consultas complexas?
  • Desempenho: é possível manter buscas, filtros e carregamento de questões rápidos mesmo com centenas de milhares de registros?
  • Next.js: a arquitetura continua gerenciável quando o projeto cresce e ganha funcionalidades mais complexas?
  • Vercel: existem limitações de infraestrutura, custos inesperados ou problemas de escalabilidade?
  • Autenticação e usuários: o Supabase Auth atende bem a uma plataforma com contas individuais, histórico de desempenho e acompanhamento de estudos?
  • Revisão espaçada: alguém já implementou algoritmos de revisão inteligente e processamento personalizado para cada usuário nessa stack?

Minha preocupação principal é construir uma arquitetura que funcione bem não apenas no início, mas também quando a plataforma tiver uma base grande de questões, muitos usuários, histórico individual de desempenho e processamento de revisões diárias.

Alguém já construiu ou mantém algo semelhante? Vale a pena seguir com essa stack pensando em escalabilidade e crescimento a longo prazo?

Gostaria muito de ouvir relatos reais, inclusive problemas que encontraram no caminho e decisões arquiteturais que fariam diferente hoje.


r/nextjs • • 7d ago

Detecting AI agents like ChatGPT in Next.js 16

Thumbnail
go.vouched.id
17 Upvotes

AI agents like ChatGPT and Perplexity are browsing websites for real people now. In this blog post, I explore how hard it is to tell them apart from humans and crawlers in Next.js.


r/nextjs • • 7d ago

Is it a good idea to lazy load a form?

6 Upvotes

It’s the above-the-fold section, and it uses React Hook Form, a date-range picker, and Zod. When I lazy-load it using dynamic/Next.js imports, the page becomes much faster because it doesn’t load any UI libraries on the initial load; it only loads React and some HTML. However, because it’s above the fold, the user experience gets worse: the form looks it's broken and shows a skeleton on the first render. What do you think about this fix?


r/nextjs • • 7d ago

Weekly Showoff Weekly Showoff Thread! Share what you've created with Next.js or for the community in this thread only!

3 Upvotes

Whether you've completed a small side project, launched a major application or built something else for the community. Share it here with us.


r/nextjs • • 7d ago

if i had one agent to choose

0 Upvotes

Hello, i've been building my startup for the past 3 months using github copilot whenever i reach the limit i create a new account and it restarts, functionally copilot is enough and more than enough, but in terms of UI/UX its not performing well, my website is pretty good i've made design by myself but when i took a look on today websites my website looked from 90's, briefly i have one month before launching and i want to spend it developing UI/UX which ai model should i subscribe to?, to have the best performance limits and price also.


r/nextjs • • 8d ago

What website security issues do developers commonly overlook?

4 Upvotes

I've been reviewing common security considerations across WordPress websites and Next.js applications.

Something I've noticed is that developers often focus heavily on performance, design and functionality, while some basic security practices receive less attention.

A few examples:

  • Exposed API keys and environment variables
  • Missing server-side authorization checks
  • Outdated dependencies and plugins
  • Improper input validation
  • Insecure file uploads
  • Missing backup and recovery strategies

I think security should be part of the development process from the beginning, rather than something added just before launch.

I'm interested in hearing from developers who maintain production websites.

Questions:

  1. What security vulnerability have you encountered most often?
  2. Do you perform security checks before every deployment?
  3. What tools do you use for dependency and vulnerability scanning?
  4. Do you follow a security checklist for WordPress and Next.js projects?

Interested in practical experiences and recommendations.


r/nextjs • • 8d ago

Next JS + Sanity CMS for a small restaurant?

Thumbnail reddit.com
3 Upvotes

r/nextjs • • 8d ago

who in your company can answer "what happened to this customer's order" without pinging a dev?

0 Upvotes

think about your own next app for a sec

customer writes in: "i paid but my booking isnt confirmed". support has to answer them. what do they open?

- sentry? only if something threw. a server action that returns { error: "card declined" } is a 200, sentry never hears about it

- vercel logs. per function, raw json, and the confirmation job ran in a worker somewhere else. no support person is reading that

- posthog shows the clicks, not what the backend did after

- admin panel shows the booking as it is now, not what happened to it

- the audit table someone built in 2023 that covers half the models

so it lands in slack. "can someone check what happened to booking 4182". a dev drops what theyre doing, opens 3 tools, stitches the request + the jobs + the db writes together in their head and types back one sentence. support pastes it to the customer. couple times a day

and now with ai agents calling endpoints at night its the same thing again. "what did the agent do" = ask a dev

theres great tooling for "is the app up" and "where did it crash". i couldnt find anything for "what happened, in words someone outside eng can read", so i ended up building my own thing for it (not linking it, rules). but before i go further i want to know if im missing something obvious

how does your team handle this? or is it a dev on slack forever


r/nextjs • • 9d ago

a loading.tsx above my static pages moved all the real text out of <main>

5 Upvotes

next 16, app router. i added a loading.tsx in my [festival] segment (along with error and not-found pages). every page under it is prerendered.

a few days later my own audit script, which counts the words inside <main> in the raw html, said almost every page had about one word. in view-source, main only had the loading placeholder. the actual content was further down in a hidden div with a small script that swaps it in after load.

i deleted the loading.tsx and the text went right back into main. caught it before it went live, and i already had a transition on link clicks so i didn’t miss the loading state.

what i couldn’t figure out: does this actually matter for google/google adsense, since it runs js and the text is technically still in the html? or did it mostly just break my audit. and is there a way to keep a loading.tsx there without this happening