Framework-agnostic SEO analysis engines, types, and utilities
Package Exports
@power-seo/core
Readme
@power-seo/core
Framework-agnostic SEO utilities, types, and engines — the shared foundation of the entire @power-seo ecosystem, usable as a standalone TypeScript library that works anywhere.
@power-seo/core is the foundational library shared by all 17 @power-seo packages. It delivers pixel-accurate meta validators, structured meta and link tag builders, URL normalization, keyword density analysis, text statistics, Open Graph and Twitter Card builders, robots directive generation, title template engines, and a token-bucket rate limiter — all in a single zero-dependency TypeScript package. Think of it as combining next-seo, seo-utils, keyword-density, url-normalize, and text-statistics into one unified, tree-shakeable library that runs in Next.js, Remix, Vite, vanilla Node.js, Cloudflare Workers, and Vercel Edge. All 8 utility modules are fully configurable and independently importable.
Zero runtime dependencies — installs clean with nothing else to pull in.
Title template engine — applyTitleTemplate() and createTitleTemplate() with %variable% substitution and separator cleanup
Pixel-accurate meta validators — validateTitle() and validateMetaDescription() measure real SERP pixel widths using Arial font metrics
URL utilities — resolveCanonical(), normalizeUrl(), toSlug(), stripTrackingParams(), extractSlug(), and more
Text statistics engine — getTextStatistics() returns word, sentence, paragraph, syllable, and character counts from HTML
Keyword density calculator — calculateKeywordDensity() and analyzeKeyphraseOccurrences() for single and multi-word keyphrases
Robots directive builder — buildRobotsContent() and parseRobotsContent() for structured robots meta directives
Rate limiting — token bucket implementation with createTokenBucket(), consumeToken(), and getWaitTime()
SEO constants — exported TITLE_MAX_PIXELS, META_DESCRIPTION_MAX_PIXELS, KEYWORD_DENSITY, READABILITY, OG_IMAGE, AI_CRAWLERS, and SCHEMA_TYPES
25+ shared TypeScript types — SEOConfig, MetaTag, LinkTag, OpenGraphConfig, TwitterCardConfig, ContentAnalysisInput, and more
Framework-agnostic — works in Next.js, Remix, Gatsby, Vite, vanilla Node.js, Edge
Tree-shakeable — "sideEffects": false with named exports per module; import only what you use
Comparison
Feature
@power-seo/core
next-seo
seo-utils
keyword-density
text-statistics
Meta tag builder
✅
Partial
❌
❌
❌
Pixel-accurate title/meta validation
✅
❌
❌
❌
❌
Open Graph builder
✅
Partial
❌
❌
❌
Twitter Card builder
✅
Partial
❌
❌
❌
Keyphrase density calculator
✅
❌
❌
✅
❌
Keyphrase occurrence analysis
✅
❌
❌
❌
❌
Robots directive builder
✅
Partial
❌
❌
❌
URL normalization + slug
✅
❌
Partial
❌
❌
Text statistics engine
✅
❌
❌
❌
Partial
Title template engine
✅
Partial
❌
❌
❌
Hreflang builder
✅
Partial
❌
❌
❌
Rate limiting utility
✅
❌
❌
❌
❌
25+ shared SEO types
✅
Partial
❌
❌
❌
TypeScript-first
✅
Partial
❌
❌
❌
Zero runtime dependencies
✅
❌
❌
❌
❌
Installation
npminstall @power-seo/core
yarnadd @power-seo/core
pnpmadd @power-seo/core
Quick Start
import{ buildMetaTags, buildLinkTags, validateTitle, resolveCanonical }from'@power-seo/core';const tags =buildMetaTags({
description:'Master SEO in Next.js with structured data and meta tags.',
openGraph:{
type:'article',
title:'Next.js SEO Guide',
images:[{ url:'https://example.com/og.jpg', width:1200, height:630}],},
twitter:{ cardType:'summary_large_image', site:'@mysite'},});const links =buildLinkTags({
canonical:resolveCanonical('https://example.com','/nextjs-seo'),});const titleCheck =validateTitle('Next.js SEO Best Practices Guide');console.log(titleCheck.valid);// trueconsole.log(titleCheck.pixelWidth);// ~291 (well under 580px limit)
Validation severity levels:
error — field is missing or critically invalid
warning — field exists but fails recommended limits
info — field passes all checks
Usage
Building Meta Tags
buildMetaTags() assembles a flat array of MetaTag objects from a typed SEOConfig. Frameworks render these into actual <meta> HTML elements.
import{ buildMetaTags }from'@power-seo/core';const tags =buildMetaTags({
description:'A TypeScript-first SEO library for modern JavaScript frameworks.',
robots:{ index:true, follow:true, maxSnippet:150, maxImagePreview:'large'},
openGraph:{
type:'website',
title:'@power-seo/core',
siteName:'My Site',
locale:'en_US',
images:[{ url:'https://example.com/og.jpg', width:1200, height:630, alt:'SEO Core'}],},
twitter:{
cardType:'summary_large_image',
site:'@mysite',
creator:'@author',
image:'https://example.com/twitter.jpg',},});// tags → MetaTag[] — pass to your framework's meta renderer
Validating Titles and Meta Descriptions
validateTitle() and validateMetaDescription() calculate the real pixel width Google uses for SERP truncation — not just character count.
import{ validateTitle, validateMetaDescription }from'@power-seo/core';const title =validateTitle('Best Running Shoes for Beginners — 2026 Guide');// { valid: true, severity: 'info', charCount: 46, pixelWidth: 316.8 }const meta =validateMetaDescription('Discover expert-reviewed running shoes for beginners.');// { valid: true, severity: 'warning', charCount: 52, pixelWidth: 335.3 }// → short (under 120 chars), suggests expanding to 120–160 chars
URL Utilities
import{
resolveCanonical,
normalizeUrl,
toSlug,
stripTrackingParams,
extractSlug,
isAbsoluteUrl,}from'@power-seo/core';resolveCanonical('https://example.com','/blog/post');// => "https://example.com/blog/post"toSlug('My Blog Post Title! — 2026');// => "my-blog-post-title-2026"stripTrackingParams('https://example.com/page?utm_source=twitter&id=123');// => "https://example.com/page?id=123"extractSlug('https://example.com/blog/my-post');// => "my-post"
import{ createTitleTemplate, applyTitleTemplate }from'@power-seo/core';const makeTitle =createTitleTemplate({ siteName:'My Site', separator:'—'});makeTitle('About Us');// => "About Us — My Site"makeTitle('Contact',{ separator:'|'});// => "Contact | My Site"applyTitleTemplate('%title% | %siteName% — Page %page%',{
title:'Blog',
siteName:'My Site',
page:2,});// => "Blog | My Site — Page 2"
Rate Limiting
import{ createTokenBucket, consumeToken, getWaitTime, sleep }from'@power-seo/core';const bucket =createTokenBucket(60);// 60 requests per minuteasyncfunctioncallApi(){if(!consumeToken(bucket)){const waitMs =getWaitTime(bucket);awaitsleep(waitMs);}// make your rate-limited API call}
Inside a CI Content Quality Gate
Block deploys when keyword density or word count fail:
import{ calculateKeywordDensity, getTextStatistics }from'@power-seo/core';const stats =getTextStatistics(bodyHtml);const density =calculateKeywordDensity(keyphrase, bodyHtml);if(stats.wordCount <300){console.error(`✗ Word count too low: ${stats.wordCount} (minimum 300)`);
process.exit(1);}if(density.density <0.5|| density.density >2.5){console.error(`✗ Keyword density out of range: ${density.density}% (target 0.5–2.5%)`);
process.exit(1);}
API Reference
Entry Points
Import
Description
@power-seo/core
All utilities, types, constants, builders, and validators
Meta Builder Functions
Function
Description
buildMetaTags(config)
Build MetaTag[] array from SEOConfig
buildLinkTags(config)
Build LinkTag[] including canonical and hreflang
buildOpenGraphTags(og)
Build Open Graph MetaTag[] from OpenGraphConfig
buildTwitterTags(twitter)
Build Twitter Card MetaTag[] from TwitterCardConfig
buildHreflangTags(alternates)
Build hreflang LinkTag[] from HreflangConfig[]
resolveTitle(config)
Resolve final title applying template if set
Meta Validator Functions
Function
Description
validateTitle(title)
Validate title — char count, pixel width, severity
validateMetaDescription(desc)
Validate meta description — char count, pixel width, severity
calculatePixelWidth(text)
Calculate SERP pixel width using Arial font metrics
CyberCraft Bangladesh is a Bangladesh-based enterprise-grade software development and Full Stack SEO service provider company specializing in ERP system development, AI-powered SaaS and business applications, full-stack SEO services, custom website development, and scalable eCommerce platforms. We design and develop intelligent, automation-driven SaaS and enterprise solutions that help startups, SMEs, NGOs, educational institutes, and large organizations streamline operations, enhance digital visibility, and accelerate growth through modern cloud-native technologies.