Skip to main content

Next.js Prompt to Optimize SEO and Core Web Vitals

Optimize a Next.js app for SEO and Core Web Vitals with metadata, structured data, sitemaps, image optimization and performance.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt

                                

What this prompt does

This prompt turns an AI assistant into a Next.js SEO and performance engineer. It takes your [nextjs_version] and current [current_lcp] and [current_cls] scores, then walks through ten concrete deliverables: dynamic metadata via generateMetadata, JSON-LD structured data, a generated sitemap, robots.txt, next/image with blur placeholders, font and script optimization, OpenGraph tags, canonical handling, and a Lighthouse CI GitHub Action.

The structure works because it pins the AI to real, named Next.js APIs rather than vague advice. Feeding in your starting [current_lcp] and [current_cls] gives the model a baseline to optimize against the explicit targets (LCP < 2.5s, CLS < 0.1, FID < 100ms), so the output is corrective, not generic. The [page_types] and [schema_types] variables decide which routes get metadata and which Schema.org entities get emitted, while [url_patterns] shapes the canonical logic for paginated and localized pages.

When to use it

  • You shipped a Next.js app and Lighthouse or Search Console flags weak Core Web Vitals
  • You need generateMetadata and JSON-LD wired up across several [page_types] consistently
  • You want a dynamic sitemap.xml and correct canonical URLs for [url_patterns]
  • You keep regressing Core Web Vitals on deploys and want Lighthouse CI as a guardrail
  • You're standardizing a reusable SEO component instead of copy-pasting meta tags
  • You're migrating from the Pages Router and need App Router metadata patterns

Example output

Expect a structured implementation plan with code: a reusable SEO/metadata component, generateMetadata functions per route group, JSON-LD snippets for each of your [schema_types], a sitemap.ts using generateSitemaps, a next/font and next/script configuration, and a Lighthouse CI workflow YAML. It reads like a checklist you can implement file by file rather than a single paste-ready blob.

Pro tips

  • Set [current_lcp] and [current_cls] to your real measured numbers so the model prioritizes your actual bottleneck instead of guessing
  • Trim [page_types] to the routes that actually matter for search; metadata on low-value pages is noise
  • Match [schema_types] to your real content; emitting Product schema on a blog invites rich-result errors
  • Be specific with [url_patterns] — paginated lists and localized routes are where canonical bugs hide
  • I cap the scope to a few [page_types] first, verify the wins in Lighthouse, then expand, rather than refactoring everything at once
  • Always keep the Lighthouse CI step; a good score regresses quietly the moment it isn't enforced on every deploy

Frequently Asked Questions

Does this prompt work with both the App Router and Pages Router?
It is written around App Router APIs like generateMetadata and generateSitemaps, which assume Next.js 13+. If your `[nextjs_version]` uses the Pages Router, tell the model so it can suggest the next/head and getServerSideProps equivalents instead.
Will it actually improve my Core Web Vitals or just describe them?
It produces concrete code changes — image blur placeholders, font preloading, script strategies — that target LCP, CLS, and FID directly. The real improvement still depends on your bottleneck, which is why setting accurate `[current_lcp]` and `[current_cls]` values matters.
Can I use it for JSON-LD structured data only?
Yes. You can ignore the other deliverables and ask it to focus on the JSON-LD step, generating Schema.org markup for the `[schema_types]` you list. Validate the output in Google's Rich Results Test before shipping.
Does the Lighthouse CI part require GitHub?
The prompt generates a GitHub Action workflow by default, but Lighthouse CI runs on any CI provider. Ask the model to output a GitLab CI or CircleCI config instead if that matches your pipeline.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in React & Next.js Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support