r/nextjs • • 5d 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

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

Post image
2 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 • • 23h ago

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

31 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 • • 1d 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 • • 2d ago

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

13 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 • • 2d ago Bravo

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

25 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 • • 3d ago

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

19 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 • • 3d 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 • • 4d ago

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

Thumbnail reddit.com
0 Upvotes

r/nextjs • • 4d ago

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

Thumbnail reddit.com
0 Upvotes

r/nextjs • • 5d 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 • • 4d 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 • • 5d 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 • • 5d 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 • • 5d 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 • • 6d 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 • • 6d ago

Next JS + Sanity CMS for a small restaurant?

Thumbnail reddit.com
3 Upvotes

r/nextjs • • 6d 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 • • 7d 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


r/nextjs • • 8d ago

With a slow client chunk, a non-transition state update made React discard server HTML under loading.tsx

4 Upvotes

On a client's storefront (next 16.3.0, react-dom 19.2.4) the product configurator page showed a blank spinner for about 1.4 s instead of the server-rendered page.

An e2e test caught it during development work. It runs against the production server and answers the one client chunk that holds the page root 1500 ms late, to widen the race. At the base commit it was red on both browser projects.

Same result on 3 of 3 loads. The useId-style ids had changed to client ids (our log says the tab ids became _r_0_) and the server-rendered <main> had been replaced. React threw the server HTML away and client-rendered the segment, with no console error.

The trigger was our analytics provider, a client component in the layout above the route segment. For a returning visitor with consent already stored, it called setConsent in an effect, outside any transition. That update reached the loading.tsx Suspense boundary while the boundary was still dehydrated.

We wrapped the provider's two mount-time updates in startTransition. Roughly, with a placeholder value, one of them now reads:

useEffect(() => {
  startTransition(() => {
    setConsent(value);
  });
}, []);

The test went green, 6/6.

Our notes say a transition that reaches a dehydrated boundary is held back, whereas a default-lane update is committed and discards the server HTML. Grant and deny on click stay urgent, because the banner has to close on click.

What it costs, measured after the fix: with the chunk 3000 ms late, the server-rendered cookie banner was still visible at 1500 ms, because it stays until hydration, and a tap in that window still discards the server HTML. After Reject, the opt-out happens one render later, 48 ms later than before the fix. No analytics event goes out without consent.

In a probe, next-themes discarded the server HTML the same way when the stored theme differed from the OS theme. We haven't fixed that, and it went into a follow-up task.


r/nextjs • • 8d ago

Ecommerce with nextjs

7 Upvotes

i am planning to build an ecommerce store using meduSA js...any sugestions other than medusajs ?


r/nextjs • • 8d ago

Next.js 16 on Cloudflare Workers: CPU per request went from ~450 ms to ~100 ms. What actually moved it

6 Upvotes

I run Next.js 16 on Cloudflare Workers through OpenNext: a prerendered marketing site in 17 languages, a dashboard and public pages. For weeks, Workers analytics showed about 450 ms of CPU per request. It's about 100 ms now, and the slow tail of uncached renders (p90 across 20 probes worldwide) went from ~9.9 s to ~3.6 s. What did it:

1. Sentry's Node SDK was inside the Worker. Next builds the server for Node, so @sentry/nextjs bundled its Node SDK. It never even started in the Worker, but it was a quarter of the script and a third of every cold start. Point the server at Sentry's edge build:

// next.config.ts
function sentryBuild(file: string) {
  const pkg = path.dirname(require.resolve('@sentry/nextjs/package.json'));
  return `./${path.relative(__dirname, path.join(pkg, 'build/esm', file))}`;
}

const nextConfig: NextConfig = {
  turbopack: {
    resolveAlias: {
      '@sentry/nextjs': {
        browser: sentryBuild('index.client.js'),
        default: sentryBuild('edge/index.js')
      }
    }
  }
};

2. Script size is startup time. A Worker parses its whole script on every cold start. Ours was 37 MiB raw, half of it marketing text: every language's MDX and message catalogs compiled into the bundle. Moving that text to static assets, read at render through the ASSETS binding, brought it to 18 MiB, and Wrangler now reports 28 ms of startup.

3. A cookie keeps a page out of the edge cache. next-intl sets a locale cookie on the first visit, and the cache won't store a response with Set-Cookie. So every first visit and every crawler missed the cache. This stores the page without that one header:

Cache-Control: public, max-age=86400, stale-while-revalidate=86400, private="set-cookie"

The first visitor still gets the cookie, and everyone after is served from the edge.

4. Don't ask your auth server on every request. Verify the session JWT locally. A fresh isolate fetching the signing keys from a cold auth API waited up to 1.4 s, so the keys now go through the Cache API, which all isolates in a data center share.

5. A server action that sets a cookie re-renders the whole page. D1's read replicas need a session bookmark that travels in a cookie, so every server action set one, and Next re-rendered the full page after each write. Writes now go through a route handler; server actions are left for flows that end in a redirect.

6. The static-assets incremental cache is fast and read-only. Every page it serves has to be prerendered (dynamicParams = false), and nothing revalidates. Fine for a marketing site, but plan for it.

7. Watch the network tab after an OpenNext upgrade. With enableCacheInterception, @opennextjs/aws 4.1.0 answered the router's segment prefetches with the whole page, and open tabs kept prefetching in a loop. 4.1.6 fixed it.

One thing I haven't solved: telling cold requests from warm ones. I read CPU from Workers analytics and time to first byte from Globalping probes, but which requests were cold is still guesswork. How do you measure it?


r/nextjs • • 8d ago

After a 3-week break, I'm back to shipping weekly: built a zero-dependency Biometric Hold-to-Authorize button in React & Tailwind

0 Upvotes

Hey devs! I'm building a cyberpunk UI library for Next.js & Tailwind CSS built strictly with native React hooks and zero external animation libraries.

This week's drop is a Biometric Hold-to-Authorize security button with a real-time laser progress scan and verification lock. It uses Pointer Events so it works cleanly on both desktop and mobile touchscreens without triggering context menus.

What security or sci-fi UI interaction should I build for next Tuesday's drop?


r/nextjs • • 9d ago

Cms with next.js?

27 Upvotes

Hi all I making a lot of sites in next js for clients but what’s a good cms that they can log in and manage editable regions etc themselves