{"_id":"@capyseo/sveltekit","_rev":"2-1292b09d60ea7d1902be4d750baa8aeb","name":"@capyseo/sveltekit","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.0":{"name":"@capyseo/sveltekit","version":"0.1.0","keywords":["seo","sveltekit","svelte","vite","vite-plugin","analyzer","seo-analyzer","meta-tags","accessibility","web-vitals"],"author":{"name":"Capyseo","email":"hello@capyseo.dev"},"license":"MIT","_id":"@capyseo/sveltekit@0.1.0","maintainers":[{"name":"hffmnnj","email":"npm@jhpass.com"}],"homepage":"https://capyseo.dev","bugs":{"url":"https://github.com/capyseo/adapter-sveltekit/issues"},"dist":{"shasum":"81bffc5b719d9fb8c57d31cbab848dfaf69cc719","tarball":"https://registry.npmjs.org/@capyseo/sveltekit/-/sveltekit-0.1.0.tgz","fileCount":13,"integrity":"sha512-mWtWz0oNwXLIBoWz/ETA+dRFpv6WsIqyVtkbIbbyPzwxq+PE5Y/G51fcn04FQOE7tH/cRCnl4AJ5kT2yEplV+Q==","signatures":[{"sig":"MEUCIQCbAorOmSjVHl+wQV2oa+WR/OVLqqEv55AkGMUZ2HWzbwIgNiFUZ0HU42gkPs26XziKzHuhjtJQD2vUOuL94V3lshU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":76781},"type":"module","svelte":"./dist/index.js","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","svelte":"./dist/index.js"},"./vite":{"types":"./dist/vite-plugin.d.ts","import":"./dist/vite-plugin.js"},"./hooks":{"types":"./dist/hooks.d.ts","import":"./dist/hooks.js"}},"gitHead":"e18cdaa81ccd5f89acd8ef243c1fb714594c7ff7","scripts":{"dev":"tsup --watch","lint":"biome check src","build":"tsup","format":"biome format --write src","prepublishOnly":"npm run build"},"_npmUser":{"name":"hffmnnj","email":"npm@jhpass.com"},"repository":{"url":"git+https://github.com/capyseo/adapter-sveltekit.git","type":"git"},"_npmVersion":"11.6.4","description":"SvelteKit integration for Capyseo SEO analyzer - analyze pages during development and build","directories":{},"sideEffects":false,"_nodeVersion":"25.2.1","dependencies":{"@capyseo/core":"^0.1.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.0","svelte":"^5.0.0","typescript":"^5.7.0","@types/node":"^22.0.0","@biomejs/biome":"^1.9.0"},"peerDependencies":{"vite":"^5.0.0 || ^6.0.0","svelte":"^4.0.0 || ^5.0.0","@sveltejs/kit":"^2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/sveltekit_0.1.0_1765171357276_0.5330532078431298","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@capyseo/sveltekit","version":"0.1.2","description":"SvelteKit integration for Capyseo SEO analyzer - analyze pages during development and build","type":"module","license":"MIT","author":{"name":"Capyseo","email":"hello@capyseo.dev"},"homepage":"https://capyseo.dev","repository":{"type":"git","url":"git+https://github.com/Capyseo/capyseo-sveltekit.git"},"bugs":{"url":"https://github.com/Capyseo/capyseo-sveltekit/issues"},"keywords":["seo","sveltekit","svelte","vite","vite-plugin","analyzer","seo-analyzer","meta-tags","accessibility","web-vitals"],"engines":{"node":">=18"},"sideEffects":false,"svelte":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","svelte":"./dist/index.js","import":"./dist/index.js"},"./vite":{"types":"./dist/vite-plugin.d.ts","import":"./dist/vite-plugin.js"},"./hooks":{"types":"./dist/hooks.d.ts","import":"./dist/hooks.js"}},"scripts":{"build":"tsup","dev":"tsup --watch","lint":"biome check src","format":"biome format --write src","prepublishOnly":"npm run build"},"dependencies":{"@capyseo/core":"^0.1.0"},"devDependencies":{"@biomejs/biome":"^1.9.0","@types/node":"^22.0.0","svelte":"^5.0.0","tsup":"^8.3.0","typescript":"^5.7.0"},"peerDependencies":{"@sveltejs/kit":"^2.0.0","svelte":"^4.0.0 || ^5.0.0","vite":"^5.0.0 || ^6.0.0"},"_id":"@capyseo/sveltekit@0.1.2","gitHead":"c3dfbd09225e7e8dc1ce0a9eb575be0f537eef9a","_nodeVersion":"20.19.6","_npmVersion":"10.8.2","dist":{"integrity":"sha512-q9tNYyIjHuQqhIv+RAzBFOj3weu4bBlLr/+EG44ARPIu/z1mXorHEeXR5IgjH6FokutQzp/bdwvDd7Z5KukSMw==","shasum":"f6692e4c6e375fa9a60472db482b4b2aa719b88c","tarball":"https://registry.npmjs.org/@capyseo/sveltekit/-/sveltekit-0.1.2.tgz","fileCount":13,"unpackedSize":76781,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@capyseo%2fsveltekit@0.1.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDW99ngvk368pMDvS94riGVUfGlo/bb0zbhYHJ8JelVhwIhAP3lbQ8tDLPw6vKTHGfbqIoAiWtGaCz7/xYG09UjO1jw"}]},"_npmUser":{"name":"hffmnnj","email":"npm@jhpass.com"},"directories":{},"maintainers":[{"name":"hffmnnj","email":"npm@jhpass.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sveltekit_0.1.2_1765172584827_0.955488219641516"},"_hasShrinkwrap":false}},"time":{"created":"2025-12-08T05:22:37.194Z","modified":"2025-12-08T05:43:05.347Z","0.1.0":"2025-12-08T05:22:37.429Z","0.1.2":"2025-12-08T05:43:04.973Z"},"bugs":{"url":"https://github.com/Capyseo/capyseo-sveltekit/issues"},"author":{"name":"Capyseo","email":"hello@capyseo.dev"},"license":"MIT","homepage":"https://capyseo.dev","keywords":["seo","sveltekit","svelte","vite","vite-plugin","analyzer","seo-analyzer","meta-tags","accessibility","web-vitals"],"repository":{"type":"git","url":"git+https://github.com/Capyseo/capyseo-sveltekit.git"},"description":"SvelteKit integration for Capyseo SEO analyzer - analyze pages during development and build","maintainers":[{"name":"hffmnnj","email":"npm@jhpass.com"}],"readme":"# @capyseo/sveltekit\n\n**SvelteKit integration** for Capyseo with Vite plugin and dev-time server hooks.\n\n![Capyseo SvelteKit](assets/capyseo-sveltekit-banner.png)\n\n[![npm version](https://img.shields.io/npm/v/@capyseo/sveltekit.svg)](https://www.npmjs.com/package/@capyseo/sveltekit)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n[![SvelteKit](https://img.shields.io/badge/SvelteKit-2.x-FF3E00?logo=svelte)](https://kit.svelte.dev)\n\n**[Documentation](https://capyseo.dev/docs/sveltekit)** · **[GitHub](https://github.com/Capyseo/sveltekit)** · **[Report Issue](https://github.com/Capyseo/sveltekit/issues)**\n\n**Part of the [Capyseo](https://capyseo.dev) toolkit.**\n\n---\n\n## Overview\n\nDeep SvelteKit integration for the Capyseo SEO analyzer. Get real-time SEO feedback during development and enforce SEO quality in your CI/CD pipeline.\n\n---\n\n## Why Use This?\n\nWhile you can use the CLI to analyze any built site, this package provides **SvelteKit-specific integrations** that make SEO analysis seamless:\n\n- 🔌 **Vite Plugin** — Analyze your pages automatically when you build\n- 🪝 **Server Hooks** — See SEO issues in real-time as you develop\n- 🎯 **Framework-native** — Works with SvelteKit's routing, prerendering, and adapters\n- ⚡ **Zero config** — Just add the plugin and start seeing results\n\n---\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Quick Start](#quick-start)\n- [Vite Plugin (Build-time)](#vite-plugin-build-time)\n- [Server Hooks (Dev-time)](#server-hooks-dev-time)\n- [AI-Powered Suggestions](#ai-powered-suggestions)\n- [Configuration Options](#configuration-options)\n- [Examples](#examples)\n- [Troubleshooting](#troubleshooting)\n\n---\n\n## Installation\n\n```bash\n# Using npm\nnpm install @capyseo/sveltekit @capyseo/core\n\n# Using Bun (recommended)\nbun add @capyseo/sveltekit @capyseo/core\n\n# Using pnpm\npnpm add @capyseo/sveltekit @capyseo/core\n```\n\n---\n\n## Quick Start\n\n### Option 1: Vite Plugin (Recommended for CI/CD)\n\nAdd the Vite plugin to analyze pages during `vite build`:\n\n```typescript\n// vite.config.ts\nimport { sveltekit } from '@sveltejs/kit/vite';\nimport { capyseo } from '@capyseo/sveltekit/vite';\nimport { defineConfig } from 'vite';\n\nexport default defineConfig({\n  plugins: [\n    sveltekit(),\n    capyseo(),\n  ],\n});\n```\n\nNow when you run `vite build`, you'll see SEO analysis for each page.\n\n### Option 2: Server Hooks (Recommended for Development)\n\nAdd server hooks to see SEO issues in real-time as you browse your dev server:\n\n```typescript\n// src/hooks.server.ts\nimport { createCapyseoHandle } from '@capyseo/sveltekit/hooks';\n\nexport const handle = createCapyseoHandle();\n```\n\nNow visit any page on `http://localhost:5173` and check your terminal for SEO feedback.\n\n---\n\n## Vite Plugin (Build-time)\n\nThe Vite plugin analyzes your pages during `vite build`. This is ideal for:\n\n- CI/CD pipelines (fail builds on low SEO scores)\n- Pre-deployment checks\n- Generating SEO reports\n\n### Basic Setup\n\n```typescript\n// vite.config.ts\nimport { sveltekit } from '@sveltejs/kit/vite';\nimport { capyseo } from '@capyseo/sveltekit/vite';\nimport { defineConfig } from 'vite';\n\nexport default defineConfig({\n  plugins: [\n    sveltekit(),\n    capyseo({\n      // Options here\n    }),\n  ],\n});\n```\n\n### Fail Builds on Low Scores\n\nPerfect for CI/CD—prevent deploying sites with SEO issues:\n\n```typescript\ncapyseo({\n  // Fail build if any page scores below 80\n  minScore: 80,\n\n  // Fail build if there are any SEO errors\n  failOnError: true,\n})\n```\n\n### Exclude Paths\n\nSkip pages that don't need SEO analysis:\n\n```typescript\ncapyseo({\n  exclude: [\n    '/admin/*',      // Admin pages\n    '/api/*',        // API routes\n    '/preview/*',    // Preview pages\n    '/__data.json',  // SvelteKit data endpoints\n  ],\n})\n```\n\n### Enable AI Suggestions\n\nGet AI-generated meta descriptions and alt text:\n\n```typescript\ncapyseo({\n  // Using environment variable\n  geminiApiKey: process.env.GEMINI_API_KEY,\n\n  // Or specify the provider\n  aiProvider: 'openai',\n  aiApiKey: process.env.OPENAI_API_KEY,\n})\n```\n\n### Custom Report Handler\n\nProcess analysis results programmatically:\n\n```typescript\ncapyseo({\n  onReport: (reports) => {\n    // Calculate average score\n    const avg = reports.reduce((sum, r) => sum + r.score, 0) / reports.length;\n    console.log(`Average SEO score: ${avg.toFixed(1)}/100`);\n\n    // Find worst pages\n    const worst = reports.filter(r => r.score < 70);\n    if (worst.length > 0) {\n      console.log('Pages needing attention:', worst.map(r => r.url));\n    }\n\n    // Write custom report\n    fs.writeFileSync('seo-summary.json', JSON.stringify({\n      averageScore: avg,\n      totalPages: reports.length,\n      issueCount: reports.reduce((sum, r) => sum + r.issues.length, 0),\n    }));\n  },\n})\n```\n\n### Full Plugin Options\n\n```typescript\ninterface VitePluginOptions {\n  // Enable/disable analysis (defaults to true in dev)\n  analyze?: boolean;\n\n  // Minimum score to pass build (0-100)\n  minScore?: number;\n\n  // Fail build on any SEO errors\n  failOnError?: boolean;\n\n  // Paths to exclude from analysis (glob patterns)\n  exclude?: string[];\n\n  // AI provider: 'openai' | 'anthropic' | 'gemini' | 'ollama'\n  aiProvider?: string;\n\n  // API key for AI provider\n  aiApiKey?: string;\n  geminiApiKey?: string;  // Shorthand for Gemini\n\n  // Ollama base URL (default: http://localhost:11434)\n  ollamaBaseUrl?: string;\n\n  // Custom report handler\n  onReport?: (reports: Report[]) => void;\n}\n```\n\n---\n\n## Server Hooks (Dev-time)\n\nServer hooks analyze pages in real-time as you develop. This is ideal for:\n\n- Immediate feedback while coding\n- Catching SEO issues before committing\n- Learning SEO best practices\n\n### Basic Setup\n\n```typescript\n// src/hooks.server.ts\nimport { createCapyseoHandle } from '@capyseo/sveltekit/hooks';\n\nexport const handle = createCapyseoHandle();\n```\n\n### Combine with Other Hooks\n\nUsing SvelteKit's `sequence` helper:\n\n```typescript\n// src/hooks.server.ts\nimport { sequence } from '@sveltejs/kit/hooks';\nimport { createCapyseoHandle } from '@capyseo/sveltekit/hooks';\n\nconst capyseoHandle = createCapyseoHandle({\n  logLevel: 'issues',\n});\n\nconst authHandle = async ({ event, resolve }) => {\n  // Your auth logic\n  return resolve(event);\n};\n\nexport const handle = sequence(capyseoHandle, authHandle);\n```\n\n### Log Level Options\n\nControl how much output you see:\n\n```typescript\ncreateCapyseoHandle({\n  // 'none' — No output\n  // 'issues' — Only pages with SEO issues (default)\n  // 'all' — Every page analyzed\n  logLevel: 'issues',\n})\n```\n\n**Example output with `logLevel: 'issues'`:**\n\n```\n[capyseo] /about (Score: 72/100)\n  ✗ [meta-description] Missing meta description\n  ! [open-graph] Missing og:image\n```\n\n### Enable Only in Development\n\n```typescript\ncreateCapyseoHandle({\n  enabled: process.env.NODE_ENV === 'development',\n})\n```\n\n### Custom Report Handler\n\nProcess results programmatically:\n\n```typescript\ncreateCapyseoHandle({\n  onReport: (report) => {\n    // Send to monitoring service\n    if (report.score < 70) {\n      console.warn(`⚠️ Low SEO score on ${report.url}: ${report.score}/100`);\n    }\n\n    // Track specific issues\n    const missingMeta = report.issues.filter(i =>\n      i.rule === 'meta-description' || i.rule === 'meta-title'\n    );\n    if (missingMeta.length > 0) {\n      console.warn('Missing meta tags:', missingMeta);\n    }\n  },\n})\n```\n\n### Full Hooks Options\n\n```typescript\ninterface HooksOptions {\n  // Enable/disable analysis (defaults to true in dev)\n  enabled?: boolean;\n\n  // Log level: 'none' | 'issues' | 'all'\n  logLevel?: 'none' | 'issues' | 'all';\n\n  // Paths to exclude from analysis (glob patterns)\n  exclude?: string[];\n\n  // AI provider settings\n  aiProvider?: string;\n  aiApiKey?: string;\n\n  // Custom report handler (called for each page)\n  onReport?: (report: Report) => void;\n}\n```\n\n---\n\n## AI-Powered Suggestions\n\nBoth the Vite plugin and server hooks support AI-powered suggestions. When enabled, Capyseo will:\n\n- **Generate meta descriptions** — Based on your page content\n- **Suggest alt text** — For images missing descriptions\n- **Recommend improvements** — Title tweaks, keyword suggestions\n\n### Using OpenAI\n\n```typescript\n// vite.config.ts\ncapyseo({\n  aiProvider: 'openai',\n  aiApiKey: process.env.OPENAI_API_KEY,\n})\n```\n\n### Using Anthropic (Claude)\n\n```typescript\ncapyseo({\n  aiProvider: 'anthropic',\n  aiApiKey: process.env.ANTHROPIC_API_KEY,\n})\n```\n\n### Using Google Gemini\n\n```typescript\ncapyseo({\n  aiProvider: 'gemini',\n  aiApiKey: process.env.GEMINI_API_KEY,\n  // Or use the shorthand:\n  geminiApiKey: process.env.GEMINI_API_KEY,\n})\n```\n\n### Using Ollama (Free, Local)\n\nRun AI locally without API keys:\n\n1. Install Ollama: https://ollama.ai\n2. Pull a model: `ollama pull llama3.3`\n3. Configure:\n\n```typescript\ncapyseo({\n  aiProvider: 'ollama',\n  // Optional: custom URL if not running locally\n  ollamaBaseUrl: 'http://localhost:11434',\n})\n```\n\n**Recommended models by hardware:**\n\n| Hardware | Model Command |\n|----------|---------------|\n| RTX 4090 (24GB) | `ollama pull deepseek-r1:70b` |\n| RTX 4070 (12GB) | `ollama pull qwen3-coder:14b` |\n| M4 Pro (48GB) | `ollama pull deepseek-r1:70b` |\n| M4 (16GB) | `ollama pull qwen3-coder:14b` |\n| CPU only | `ollama pull phi-3:3.8b` |\n\n---\n\n## Configuration Options\n\n### Environment Variables\n\nThe plugins automatically read these environment variables:\n\n| Variable | Description |\n|----------|-------------|\n| `OPENAI_API_KEY` | OpenAI API key |\n| `ANTHROPIC_API_KEY` | Anthropic API key |\n| `GEMINI_API_KEY` | Google Gemini API key |\n| `OLLAMA_BASE_URL` | Ollama server URL (default: http://localhost:11434) |\n\n### SvelteKit Configuration\n\nFor best results, ensure your SvelteKit config outputs prerendered HTML:\n\n```typescript\n// svelte.config.js\nimport adapter from '@sveltejs/adapter-static';\n\nexport default {\n  kit: {\n    adapter: adapter({\n      fallback: 'index.html',\n    }),\n    prerender: {\n      entries: ['*'],  // Prerender all pages\n    },\n  },\n};\n```\n\n---\n\n## Examples\n\n### Minimal Setup (Dev + Build)\n\n```typescript\n// vite.config.ts\nimport { sveltekit } from '@sveltejs/kit/vite';\nimport { capyseo } from '@capyseo/sveltekit/vite';\nimport { defineConfig } from 'vite';\n\nexport default defineConfig({\n  plugins: [sveltekit(), capyseo()],\n});\n```\n\n```typescript\n// src/hooks.server.ts\nimport { createCapyseoHandle } from '@capyseo/sveltekit/hooks';\nexport const handle = createCapyseoHandle();\n```\n\n### CI/CD with GitHub Actions\n\n```yaml\n# .github/workflows/seo.yml\nname: SEO Check\n\non: [push, pull_request]\n\njobs:\n  seo:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n      - uses: oven-sh/setup-bun@v2\n\n      - run: bun install\n      - run: bun run build\n        env:\n          # Build will fail if score < 80\n          # (configured in vite.config.ts with minScore: 80)\n```\n\n### Production Setup with AI\n\n```typescript\n// vite.config.ts\nimport { sveltekit } from '@sveltejs/kit/vite';\nimport { capyseo } from '@capyseo/sveltekit/vite';\nimport { defineConfig } from 'vite';\n\nexport default defineConfig({\n  plugins: [\n    sveltekit(),\n    capyseo({\n      // Strict requirements for production\n      minScore: 85,\n      failOnError: true,\n\n      // Exclude non-public routes\n      exclude: ['/admin/*', '/api/*', '/__*'],\n\n      // AI suggestions in CI\n      aiProvider: 'gemini',\n      aiApiKey: process.env.GEMINI_API_KEY,\n\n      // Custom reporting\n      onReport: (reports) => {\n        // Write report for deployment review\n        const summary = {\n          date: new Date().toISOString(),\n          averageScore: reports.reduce((s, r) => s + r.score, 0) / reports.length,\n          pageCount: reports.length,\n          errorCount: reports.flatMap(r => r.issues).filter(i => i.severity === 'error').length,\n        };\n        fs.writeFileSync('seo-report.json', JSON.stringify(summary, null, 2));\n      },\n    }),\n  ],\n});\n```\n\n---\n\n## Troubleshooting\n\n### \"No pages analyzed\"\n\nMake sure you're building with prerendering enabled:\n\n```typescript\n// svelte.config.js\nexport default {\n  kit: {\n    prerender: {\n      entries: ['*'],\n    },\n  },\n};\n```\n\n### \"Hooks not running\"\n\n1. Check the file is named `src/hooks.server.ts` (not `src/hooks.ts`)\n2. Make sure you're exporting `handle`:\n   ```typescript\n   export const handle = createCapyseoHandle();\n   ```\n\n### \"AI suggestions not appearing\"\n\n1. Verify your API key is set:\n   ```bash\n   echo $OPENAI_API_KEY\n   ```\n\n2. Check you specified the provider:\n   ```typescript\n   capyseo({\n     aiProvider: 'openai',\n     aiApiKey: process.env.OPENAI_API_KEY,\n   })\n   ```\n\n### \"Build failing with low score\"\n\nIf `minScore` is set and pages don't meet it, the build will fail. Either:\n\n1. Fix the SEO issues (recommended)\n2. Lower the threshold:\n   ```typescript\n   capyseo({ minScore: 70 })\n   ```\n3. Exclude problem pages:\n   ```typescript\n   capyseo({ exclude: ['/draft/*'] })\n   ```\n\n---\n\n## Related Packages\n\n| Package | Description |\n|---------|-------------|\n| [@capyseo/core](https://github.com/capyseo/core) | Core analysis engine (for custom integrations) |\n| [@capyseo/cli](https://github.com/capyseo/cli) | Command-line interface (for any site) |\n\n---\n\n## Contributing\n\nSee [CONTRIBUTING.md](./CONTRIBUTING.md) for development setup and guidelines.\n\n---\n\n## Security\n\nTo report vulnerabilities, see [SECURITY.md](./SECURITY.md).\n\n---\n\n## License\n\nMIT © [Capyseo](https://capyseo.dev)\n","readmeFilename":"README.md"}