{"_id":"@adunblock/server-tag-nextjs","_rev":"4-f48acdc158d6f937820f085106f3495a","name":"@adunblock/server-tag-nextjs","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"@adunblock/server-tag-nextjs","version":"1.0.0","keywords":["nextjs","react","server-side","script-loading","typescript"],"author":{"name":"Adunblock"},"license":"ISC","_id":"@adunblock/server-tag-nextjs@1.0.0","maintainers":[{"name":"billadunblock","email":"bill@ad-unblock.com"}],"homepage":"https://github.com/adunblock/server-tag#readme","bugs":{"url":"https://github.com/adunblock/server-tag/issues"},"dist":{"shasum":"14359e1e9ac702dc455f1d459f85e93d4eccbc96","tarball":"https://registry.npmjs.org/@adunblock/server-tag-nextjs/-/server-tag-nextjs-1.0.0.tgz","fileCount":11,"integrity":"sha512-cETgkJj4vj1XCI7OJYJjp7a2GlP0zjizpNRWGIDLv7I0dv6dDW6LtVB9QApH8Htr9F+oVLlhHnSmoyb+KBh9xA==","signatures":[{"sig":"MEUCIBwIgb/gIZMstYX5OK0L2nljVkjd5qNwNM2IUjnblxiQAiEAscfy5E9vID5PGGjoHEflxO/cyzZb5u97SvdoAJEnEk4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10244},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.esm.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.esm.js","require":"./dist/index.js"}},"gitHead":"cd6cfd2abdc080ef0208f699d7cab9a76c7364d7","scripts":{"dev":"cd test-app && next dev","build":"npm run clean && tsc && tsc -p tsconfig.esm.json && npm run build:rename","clean":"rm -rf dist","test:e2e":"playwright test","test:lint":"cd test-app && next lint","test:build":"cd test-app && next build","test:start":"cd test-app && next start","build:rename":"cp dist/esm/index.js dist/index.esm.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"billadunblock","actor":{"name":"billadunblock","type":"user","email":"bill@ad-unblock.com"},"email":"bill@ad-unblock.com"},"repository":{"url":"git+https://github.com/adunblock/server-tag.git","type":"git"},"_npmVersion":"11.0.0","description":"A Next.js/React component for server-side script loading and rendering","directories":{},"_nodeVersion":"22.11.0","dependencies":{},"_hasShrinkwrap":false,"devDependencies":{"next":"15.3.4","react":"^19","eslint":"^9","react-dom":"^19","playwright":"^1.53.1","typescript":"^5","@types/node":"^20","@types/react":"^19","@eslint/eslintrc":"^3","@types/react-dom":"^19","eslint-config-next":"15.3.4"},"peerDependencies":{"next":">=12.0.0","react":">=16.8.0","react-dom":">=16.8.0"},"_npmOperationalInternal":{"tmp":"tmp/server-tag-nextjs_1.0.0_1751220666451_0.08979605136778379","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@adunblock/server-tag-nextjs","version":"1.0.1","keywords":["nextjs","react","server-side","script-loading","typescript"],"author":{"name":"Adunblock"},"license":"ISC","_id":"@adunblock/server-tag-nextjs@1.0.1","maintainers":[{"name":"billadunblock","email":"bill@ad-unblock.com"}],"homepage":"https://github.com/adunblock/adunblock-server-tag#readme","bugs":{"url":"https://github.com/adunblock/adunblock-server-tag/issues"},"dist":{"shasum":"4eac96663a0ec9468ac5be5ea3f05200bc2be626","tarball":"https://registry.npmjs.org/@adunblock/server-tag-nextjs/-/server-tag-nextjs-1.0.1.tgz","fileCount":11,"integrity":"sha512-xI3JZAHGLpreH4jh4R+jxy69aP6hQlrb3Cgsx5egj/D3oqaZZvZe0YPIs73BSEGmIu0KXHCyEhHkJsKwqZazTA==","signatures":[{"sig":"MEYCIQDbnZKBPPXGLWyRp1w9RSYGkPxeSPE6P93qO0cEsCkRbwIhAJen3iufqbHfHtoEM1ObwJSB0VJWawMwomu+FaPx05EQ","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10289},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.esm.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.esm.js","require":"./dist/index.js"}},"gitHead":"e45bcbb8124d294566ec7fdf92a37df98c9c192f","scripts":{"dev":"cd test-app && next dev","build":"npm run clean && tsc && tsc -p tsconfig.esm.json && npm run build:rename","clean":"rm -rf dist","test:e2e":"playwright test","test:lint":"cd test-app && next lint","test:build":"cd test-app && next build","test:start":"cd test-app && next start","build:rename":"cp dist/esm/index.js dist/index.esm.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"billadunblock","email":"bill@ad-unblock.com"},"repository":{"url":"git+https://github.com/adunblock/adunblock-server-tag.git","type":"git"},"_npmVersion":"10.9.2","description":"A Next.js/React component for server-side script loading and rendering","directories":{},"_nodeVersion":"22.17.1","dependencies":{},"_hasShrinkwrap":false,"devDependencies":{"next":"15.3.4","react":"^19","eslint":"^9","react-dom":"^19","playwright":"^1.53.1","typescript":"^5","@types/node":"^20","@types/react":"^19","@eslint/eslintrc":"^3","@playwright/test":"^1.53.1","@types/react-dom":"^19","eslint-config-next":"15.3.4"},"peerDependencies":{"next":">=12.0.0","react":">=16.8.0","react-dom":">=16.8.0"},"_npmOperationalInternal":{"tmp":"tmp/server-tag-nextjs_1.0.1_1755805157684_0.8886953998702773","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@adunblock/server-tag-nextjs","version":"1.0.2","keywords":["nextjs","react","server-side","script-loading","typescript"],"author":{"name":"Adunblock"},"license":"ISC","_id":"@adunblock/server-tag-nextjs@1.0.2","maintainers":[{"name":"billadunblock","email":"bill@ad-unblock.com"}],"homepage":"https://github.com/adunblock/adunblock-server-tag#readme","bugs":{"url":"https://github.com/adunblock/adunblock-server-tag/issues"},"dist":{"shasum":"86b6371fa67a51ec4c5cad151937e4e026b48891","tarball":"https://registry.npmjs.org/@adunblock/server-tag-nextjs/-/server-tag-nextjs-1.0.2.tgz","fileCount":11,"integrity":"sha512-mh6diixrc0M05I1D6GJ2A77DPtHSOmrDf8bra3ImZF0K2+3KvFMv1ERfNCtvDJLLqZHDv6FFq4t+LrLrN8Gt8w==","signatures":[{"sig":"MEYCIQCJLR+0GFYDZWlGRA8AGfIwZ3lFgTjwnNMB3xQsH6VhEQIhAOVj5kqzs823qUJmp7z14TBRri5NXFw99nub8OTVAIeI","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":11596},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.esm.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.esm.js","require":"./dist/index.js"}},"gitHead":"bce08b4440c3a051bc49e3dbee52873a0ebf790e","scripts":{"dev":"cd test-app && next dev","build":"npm run clean && tsc && tsc -p tsconfig.esm.json && npm run build:rename","clean":"rm -rf dist","test:e2e":"playwright test","test:lint":"cd test-app && next lint","test:build":"cd test-app && next build","test:start":"cd test-app && next start","build:rename":"cp dist/esm/index.js dist/index.esm.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"billadunblock","email":"bill@ad-unblock.com"},"repository":{"url":"git+https://github.com/adunblock/adunblock-server-tag.git","type":"git"},"_npmVersion":"10.9.2","description":"A Next.js/React component for server-side script loading and rendering","directories":{},"_nodeVersion":"22.17.1","dependencies":{},"_hasShrinkwrap":false,"devDependencies":{"next":"15.3.4","react":"^19","eslint":"^9","react-dom":"^19","playwright":"^1.53.1","typescript":"^5","@types/node":"^20","@types/react":"^19","@eslint/eslintrc":"^3","@playwright/test":"^1.53.1","@types/react-dom":"^19","eslint-config-next":"15.3.4"},"peerDependencies":{"next":">=12.0.0","react":">=16.8.0","react-dom":">=16.8.0"},"_npmOperationalInternal":{"tmp":"tmp/server-tag-nextjs_1.0.2_1763235926158_0.08935252921787118","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@adunblock/server-tag-nextjs","version":"1.1.0","description":"A Next.js/React component for server-side script loading and rendering","main":"dist/index.js","module":"dist/index.esm.js","types":"dist/index.d.ts","exports":{".":{"import":"./dist/index.esm.js","require":"./dist/index.js","types":"./dist/index.d.ts"}},"scripts":{"build":"npm run clean && tsc && tsc -p tsconfig.esm.json && npm run build:rename","build:rename":"cp dist/esm/index.js dist/index.esm.js","prepublishOnly":"npm run build","clean":"rm -rf dist","dev":"cd test-app && next dev","test:build":"cd test-app && next build","test:start":"cd test-app && next start","test:lint":"cd test-app && next lint","test:e2e":"playwright test"},"keywords":["nextjs","react","server-side","script-loading","typescript"],"author":{"name":"Adunblock"},"license":"ISC","repository":{"type":"git","url":"git+https://github.com/adunblock/adunblock-server-tag.git"},"peerDependencies":{"react":">=16.8.0","react-dom":">=16.8.0","next":">=12.0.0"},"dependencies":{},"devDependencies":{"@playwright/test":"^1.53.1","@types/react":"^19","@types/react-dom":"^19","@types/node":"^20","typescript":"^5","react":"^19","react-dom":"^19","next":"15.3.4","@eslint/eslintrc":"^3","eslint":"^9","eslint-config-next":"15.3.4","playwright":"^1.53.1"},"_id":"@adunblock/server-tag-nextjs@1.1.0","gitHead":"d6edac9ccb68d4067d52754540ba247e27dc6774","bugs":{"url":"https://github.com/adunblock/adunblock-server-tag/issues"},"homepage":"https://github.com/adunblock/adunblock-server-tag#readme","_nodeVersion":"22.17.1","_npmVersion":"10.9.2","dist":{"integrity":"sha512-OguiotkiSsCQ+i08gulC9ZhEv21jPoE/jH+gXVau3PiwQn+IuCeGPktncl8+a1ArG34AEVMuHvStUKPokna6qw==","shasum":"e00db87d68470cd59d1950ccb104c0c8821764fa","tarball":"https://registry.npmjs.org/@adunblock/server-tag-nextjs/-/server-tag-nextjs-1.1.0.tgz","fileCount":11,"unpackedSize":13166,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIAaQrhjbO2jiIVyHhJ3A9d+Xn6+6bL2RzU7w4wVl4VUsAiAKbqmEgNjIJjq8Lm1aO30EcR06qX4+eGb4eor34O5xeQ=="}]},"_npmUser":{"name":"billadunblock","email":"bill@ad-unblock.com"},"directories":{},"maintainers":[{"name":"billadunblock","email":"bill@ad-unblock.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/server-tag-nextjs_1.1.0_1776446768935_0.23807896695231756"},"_hasShrinkwrap":false}},"time":{"created":"2025-06-29T18:11:06.331Z","modified":"2026-04-17T17:26:09.160Z","1.0.0":"2025-06-29T18:11:06.628Z","1.0.1":"2025-08-21T19:39:17.881Z","1.0.2":"2025-11-15T19:45:26.346Z","1.1.0":"2026-04-17T17:26:09.056Z"},"bugs":{"url":"https://github.com/adunblock/adunblock-server-tag/issues"},"author":{"name":"Adunblock"},"license":"ISC","homepage":"https://github.com/adunblock/adunblock-server-tag#readme","keywords":["nextjs","react","server-side","script-loading","typescript"],"repository":{"type":"git","url":"git+https://github.com/adunblock/adunblock-server-tag.git"},"description":"A Next.js/React component for server-side script loading and rendering","maintainers":[{"name":"billadunblock","email":"bill@ad-unblock.com"}],"readme":"# @adunblock/server-tag-nextjs\n\nA Next.js React Server Component for fetching and rendering external JavaScript files on the server-side before page rendering. This package provides secure, cached script loading with TypeScript support.\n\n## Features\n\n- 🚀 **Server-Side Rendering**: Scripts are fetched and rendered on the server before page load\n- 🔒 **Security**: Built-in URL validation (HTTP/HTTPS only)\n- ⚡ **Caching**: Configurable cache interval to reduce remote requests\n- 🎯 **Custom Rendering**: Override default script rendering with custom callbacks\n- 📘 **TypeScript**: Full TypeScript support with proper type definitions\n- ✅ **Next.js 15**: Built for Next.js 15+ with React 19 support\n\n## Installation\n\n```bash\nnpm install @adunblock/server-tag-nextjs\n```\n\n## Usage\n\n### Basic Usage\n\nImport and use the `ServerTag` component in your Next.js pages or layouts:\n\n```tsx\nimport ServerTag from '@adunblock/server-tag-nextjs';\n\nexport default function MyPage() {\n  return (\n    <div>\n      <ServerTag remoteUrl=\"https://public.adunblocker.com/api/vendor_scripts\" />\n      <h1>My Page Content</h1>\n    </div>\n  );\n}\n```\n\n### Expected Remote Response Format\n\nThe remote URL should return a JSON response in this format (array directly):\n\n```json\n[\n  \"https://example.com/script1.js\",\n  \"https://example.com/script2.js\"\n]\n```\n\nThe default endpoint is `https://public.adunblocker.com/api/vendor_scripts`.\n\n> **Note**: For backward compatibility, the package also supports the legacy format `{\"js\": [...]}` but the new format (array directly) is preferred.\n\n### Advanced Usage with Custom Caching\n\n```tsx\nimport ServerTag from '@adunblock/server-tag-nextjs';\n\nexport default function MyPage() {\n  return (\n    <div>\n      <ServerTag\n        remoteUrl=\"https://public.adunblocker.com/api/vendor_scripts\"\n        cacheInterval={600} // Cache for 10 minutes (default: 300 seconds)\n      />\n      <h1>My Page Content</h1>\n    </div>\n  );\n}\n```\n\n### Custom Script Attributes\n\nPass extra attributes (including `data-*`) that should be rendered on every generated `<script>` tag:\n\n```tsx\nimport ServerTag from '@adunblock/server-tag-nextjs';\n\nexport default function MyPage() {\n  return (\n    <ServerTag\n      remoteUrl=\"https://public.adunblocker.com/api/vendor_scripts\"\n      scriptAttributes={{\n        'data-code': 'abc123',\n        'data-source': 'server-tag',\n        defer: true,\n      }}\n    />\n  );\n}\n```\n\nRendering rules:\n\n- `true` → bare attribute (e.g. `defer`)\n- `false` / `undefined` / `null` → omitted\n- any other value → `key=\"value\"`\n\n`scriptAttributes` also lets you override the default `strategy=\"beforeInteractive\"` if you pass a `strategy` key.\n\n### Custom Script Rendering\n\nOverride the default script rendering with a custom callback:\n\n```tsx\nimport ServerTag from '@adunblock/server-tag-nextjs';\nimport Script from 'next/script';\n\nexport default function MyPage() {\n  return (\n    <div>\n      <ServerTag\n        remoteUrl=\"https://public.adunblocker.com/api/vendor_scripts\"\n        renderScript={({ js }) =>\n          js.map((src) => (\n            <Script \n              key={src} \n              src={src} \n              strategy=\"lazyOnload\"\n              onLoad={() => console.log(`Loaded: ${src}`)}\n            />\n          ))\n        }\n      />\n      <h1>My Page Content</h1>\n    </div>\n  );\n}\n```\n\n## API Reference\n\n### Props\n\n| Prop | Type | Default | Description |\n|------|------|---------|-------------|\n| `remoteUrl` | `string` | Required | The URL to fetch script URLs from |\n| `cacheInterval` | `number` | `300` | Cache duration in seconds |\n| `scriptAttributes` | `ScriptAttributes` | `undefined` | Extra attributes applied to every generated `<script>` tag (e.g. `data-code`) |\n| `renderScript` | `function` | `undefined` | Custom script rendering function |\n\n### Types\n\n```typescript\ntype ScriptAttributeValue = string | boolean | number | undefined;\n\ninterface ScriptAttributes {\n  [key: string]: ScriptAttributeValue;\n}\n\ninterface ServerTagProps {\n  remoteUrl: string;\n  cacheInterval?: number;\n  scriptAttributes?: ScriptAttributes;\n  renderScript?: (jsFiles: { js: string[] }) => React.ReactNode;\n}\n```\n\n## Development\n\n### Local Testing\n\n```bash\n# Install dependencies\nnpm install\n\n# Run development server\nnpm run dev\n\n# Build the package\nnpm run build\n\n# Run E2E tests\nnpm run test:e2e\n```\n\n### Project Structure\n\n```\nnodejs/nextjs/\n├── src/\n│   ├── ServerTag.tsx    # Main component\n│   └── index.ts         # Package entry point\n├── test-app/            # Next.js test application\n├── e2e/                 # Playwright E2E tests\n└── dist/                # Built package files\n```\n\n## Security\n\n- Only HTTP and HTTPS URLs are allowed\n- Server-side execution prevents client-side script injection\n- URL validation prevents malicious protocol usage\n\n## Browser Compatibility\n\nThis package works with all browsers supported by Next.js 15+ and React 19.\n\n## License\n\nISC\n\n## Repository\n\nhttps://github.com/adunblock/adunblock-server-tag","readmeFilename":"README.md"}