This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Next SEO is a plugin that makes managing SEO easier in Next.js projects. It's built with TypeScript and provides components for structured data (JSON-LD) and SEO management.
You must check these after coming up with a plan [ ] Your plan adheres to the guide found in @ADDING_NEW_COMPONENTS.md [ ] Your plan adheres to the guidelines found below
pnpm installpnpm dev # Watch mode with tsup
pnpm build # Build library codepnpm lint # Run ESLint
pnpm lint:fix # Fix ESLint issues
pnpm format # Format with Prettier
pnpm typecheck # Type checking with TypeScriptpnpm test # Run typecheck + lint only
pnpm test:unit # Run unit tests with Vitest
pnpm test:unit:watch # Watch mode for unit tests
pnpm coverage # Generate coverage report
# Requires pnpm build to run first
pnpm test:e2e # Run E2E tests with Playwright
pnpm test:e2e:ui # Run E2E tests with UIpnpm example:dev # Run example app at localhost:3001
pnpm example:build # Build example app
pnpm example:start # Start example apppnpm clean # Clean build artifacts/src- Library source code/core- Core components likeJsonLdScript/types- TypeScript type definitions/utils- Utility functions likestringify
/examples/app-router-showcase- Example Next.js app for testing/tests- Test files/unit- Unit tests (Vitest)/e2e- E2E tests (Playwright)
- tsup - For building the library (see
tsup.config.ts) - Outputs both CommonJS and ESM formats
- Path alias:
~maps to./src
- Vitest - Unit testing with React Testing Library
- Playwright - E2E testing running against example app on port 3001
- Tests use
~alias for imports
- All library code is in
/srcdirectory - The project uses pnpm workspaces with the example app
- When developing, the example app auto-starts on port 3001 for E2E tests
- Lint and format are automatically run on staged files via Husky
- The library exports both CommonJS and ESM formats with TypeScript definitions
- When adding a new component ALWAYS refer to the guide found in ADDING_NEW_COMPONENTS.md
Next SEO provides excellent developer experience by never requiring developers to manually specify @type properties. This is achieved through intelligent type definitions and process functions.
- Type Definitions: Component props use
Omit<Type, "@type">to make@typeoptional - Process Functions: Automatically add the correct
@typebased on the input - Flexible Inputs: Accept strings, objects with/without
@type, and arrays
// Developers can write this:
<ArticleJsonLd
author="John Doe" // Simple string
publisher={{ name: "ACME Corp", logo: "logo.jpg" }} // No @type needed
/>
// Process functions transform it to valid Schema.org:
{
author: { "@type": "Person", name: "John Doe" },
publisher: { "@type": "Organization", name: "ACME Corp", logo: {...} }
}- Better DX: No need to remember Schema.org type names
- Less Boilerplate: Cleaner, more readable code
- Type Safety: Full TypeScript support maintained
- Flexibility: Still accepts objects with
@typeif provided
- Always use process functions for properties accepting flexible types
- Never require
@typein component props - Use intelligent detection (e.g.,
logoproperty → Organization) - Provide sensible defaults in process functions
This pattern is fundamental to the library's design and must be maintained in all components.