Index of every page on this site: llms.txt
All skills
robotostudio avatar

/next-best-practices

@c0b29e4
Run it yourself

Next.js best practices - file conventions, RSC boundaries, data patterns, async APIs, metadata, error handling, route handlers, image/font optimization, bundling

  • 20 files
  • 78.7 KB
  • Updated 5 months ago
  • GitHub
Use this Skill: https://skilld.dev/gh/robotostudio/turbo-start-sanity/next-best-practices

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

functions.md

≈1.1k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Functions

Next.js function APIs.

Reference: https://nextjs.org/docs/app/api-reference/functions

Navigation Hooks (Client)

Hook Purpose Reference
useRouter Programmatic navigation (push, replace, back, refresh) Docs
usePathname Get current pathname Docs
useSearchParams Read URL search parameters Docs
useParams Access dynamic route parameters Docs
useSelectedLayoutSegment Active child segment (one level) Docs
useSelectedLayoutSegments All active segments below layout Docs
useLinkStatus Check link prefetch status Docs
useReportWebVitals Report Core Web Vitals metrics Docs

Server Functions

Function Purpose Reference
cookies Read/write cookies Docs
headers Read request headers Docs
draftMode Enable preview of unpublished CMS content Docs
after Run code after response finishes streaming Docs
connection Wait for connection before dynamic rendering Docs
userAgent Parse User-Agent header Docs

Generate Functions

Function Purpose Reference
generateStaticParams Pre-render dynamic routes at build time Docs
generateMetadata Dynamic metadata Docs
generateViewport Dynamic viewport config Docs
generateSitemaps Multiple sitemaps for large sites Docs
generateImageMetadata Multiple OG images per route Docs

Request/Response

Function Purpose Reference
NextRequest Extended Request with helpers Docs
NextResponse Extended Response with helpers Docs
ImageResponse Generate OG images Docs

Common Examples

Navigation

Use next/link for internal navigation instead of <a> tags.

// Bad: Plain anchor tag
<a href="/about">About</a>

// Good: Next.js Link
import Link from 'next/link'

<Link href="/about">About</Link>

Active link styling:

'use client'

import Link from 'next/link'
import { usePathname } from 'next/navigation'

export function NavLink({ href, children }) {
  const pathname = usePathname()

  return (
    <Link href={href} className={pathname === href ? 'active' : ''}>
      {children}
    </Link>
  )
}

Static Generation

// app/blog/[slug]/page.tsx
export async function generateStaticParams() {
  const posts = await getPosts()
  return posts.map((post) => ({ slug: post.slug }))
}

After Response

import { after } from 'next/server'

export async function POST(request: Request) {
  const data = await processRequest(request)

  after(async () => {
    await logAnalytics(data)
  })

  return Response.json({ success: true })
}

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at c0b29e4. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 5 months ago
user-invocable
false

README badge

README badge for robotostudio/turbo-start-sanity/next-best-practices