parityedge on npm
The official zero-dependency client SDK for ParityEdge. Deliver sub-10ms dynamic Purchasing Power Parity (PPP) localization, automated checkout promo code injection, and isolated Shadow DOM discount banners across React, Next.js, and Vanilla JavaScript.
Package Installation
Install the package using your favorite package manager. The package exports both ES Modules (ESM) and CommonJS (CJS) with complete TypeScript type definitions.
# npmnpm install parityedge# pnpmpnpm add parityedge# yarnyarn add parityedge# bunbun add parityedgeSubpath Exports Reference
The parityedge package is tree-shakable and architected into three focused entry points:
parityedgeCore & VanillaStandalone client, automated DOM price mutator, and Shadow DOM banner for Vanilla JS, Vue, Svelte, Angular, and Node.js.
parityedge/reactReact 16.8–19First-class React components and headless hooks with zero-flicker SSR hydration for React 18, React 19, Next.js 14/15, and Remix.
parityedge/nextNext.js 14/15Edge Middleware and Server Component helpers for Next.js 14 & 15 App Router. Resolves country at the edge with zero client-side waterfall.
Usage Examples
'use client';
import React from 'react';
import { ParityProvider, useParityEdge, ParityBanner } from 'parityedge/react';
// Wrap your app (or layout) with ParityProvider — one fetch for the whole tree
export function App() {
return (
<ParityProvider projectId="prj_live_your_project_id">
<PricingSection />
</ParityProvider>
);
}
export function PricingSection() {
const { data, loading, error } = useParityEdge();
if (loading) return <div>Checking localized rates...</div>;
if (error) console.warn('[ParityEdge] lookup failed, showing default price');
const basePrice = 49;
const discountedPrice = data?.eligible
? (basePrice * (1 - data.discountPercentage / 100)).toFixed(2)
: basePrice.toFixed(2);
return (
<div>
<h2 className="text-xl font-bold">Standard Plan</h2>
<p className="text-2xl font-bold">${discountedPrice} USD</p>
{/* SDK auto-mutates checkout links — no manual coupon needed */}
<a href="https://buy.stripe.com/example_checkout">
Purchase with Regional Discount
</a>
</div>
);
}
// Or drop in ParityBanner standalone — it handles its own fetch, no Provider needed
export function StandalonePage() {
return (
<div>
<ParityBanner projectId="prj_live_your_project_id" theme="dark" position="bottom-pill" />
<h2>Pro Plan — $49</h2>
</div>
);
}import { initParityEdge } from 'parityedge';
// Initialize and automatically mount banner + mutate prices
const client = await initParityEdge({
projectId: 'prj_live_your_project_id',
banner: true,
bannerPosition: 'bottom-pill', // 'bottom-pill' | 'top-bar' | 'modal'
bannerTheme: 'dark', // 'dark' | 'light' | 'glassmorphic'
autoApplyCoupon: true, // Prefills Stripe & Lemon Squeezy links
mutatePrices: true, // Rewrites [data-parity-base] elements
});
const data = client.getData();
if (data?.eligible) {
console.log(`Applied ${data.discountPercentage}% discount for ${data.countryName}`);
}Zero-Build CDN Option (jsDelivr / unpkg)
If you are working on a static HTML site, Webflow, Framer, WordPress, or Shopify store, you can load the compiled script directly from the npm CDN without any bundler:
<script src="https://cdn.jsdelivr.net/npm/parityedge/dist/parity.global.js" data-project-id="prj_live_your_project_id" data-auto-coupon="true" data-mutate-prices="true" data-banner="true" data-position="bottom-pill" data-theme="dark" async> </script>
⚠ This is a different build from the edge-served script.
The jsDelivr/npm script (cdn.jsdelivr.net/npm/parityedge/...) and the edge-served script (api.parityedge.app/v1/parity.global.js) are two separate implementations with different feature sets:
- jsDelivr/npm (~12 KB): supports
data-auto-coupon,data-mutate-prices,data-banneropt-out attributes. More configurable. - Edge-served (~8 KB): simpler IIFE — always auto-applies coupons and mutates prices. Does not read
data-auto-couponordata-mutate-prices.
Do not mix the two — test and ship with the same script URL to avoid behaviour differences between environments.
| Attribute | Default | Description |
|---|---|---|
| data-project-id | — | Your public project ID (required) |
| data-auto-coupon | true | Auto-append coupon to Stripe & Lemon Squeezy links |
| data-mutate-prices | true | Auto-update elements with data-parity-base |
| data-banner | true | Show the Shadow DOM discount banner |
| data-position | bottom-pill | bottom-pill | top-bar | modal |
| data-theme | dark | dark | light | glassmorphic |
Native browser fetch with zero third-party packages, minimizing attack surfaces and supply chain risks.
Resolves visitor purchasing power at anycast edge nodes without origin server roundtrips.
Automatically prevents VPN and cloud proxy exploitation at the edge.
Frequently Asked Questions (npm package)
How do I search for or install the parityedge npm package?
You can find it on npmjs.com under parityedge, or install it directly using npm install parityedge. It is a zero-dependency universal SDK compatible with all major JavaScript and TypeScript environments.
What frameworks does the parityedge npm package support?
parityedge supports React 16.8–19, Next.js 14/15 (App Router & Pages Router), Vue 3, Nuxt 3, Svelte, SvelteKit, Angular, Remix, Astro, Node.js (>=18), and plain HTML/JS script embeds via CDN.
How does ParityEdge prevent users from spoofing country location via VPN?
ParityEdge evaluates visitor Autonomous System Numbers (ASNs) against 500+ commercial datacenter and VPN providers at the Anycast edge. VPN traffic is immediately served standard baseline pricing, preventing discount abuse.