π§·Inline Script (Frontend)
DevPayr SDK
The official JavaScript SDK for integrating DevPayr into your web or SaaS application. Use this SDK to verify license keys, enforce project-based payments, and load secure injectables dynamically.
π§ Installation
You can either include the SDK directly in your HTML, or install it via npm/yarn for Node.js/ESM/CommonJS use.
β€ Browser (via CDN or direct file)
<script src="https://cdn.jsdelivr.net/npm/@devpayr/frontend-sdk@latest/dist/devpayr-frontend.js"></script>β€ Node.js / Build Tools
npm install @devpayr/frontend-sdk// ESM
import '@devpayr/frontend-sdk';
// CommonJS
require('@devpayr/frontend-sdk');π Usage
Before the SDK initializes, you must define a global config object in the browserβs window scope. This object allows the DevPayr SDK to read your license, configure behavior, and optionally handle secure injectables.
β Basic Usage
π» Minimal Modal with Default Text
This shows the default DevPayr modal with fallback messaging when license is invalid or expired.
π¨ Fully Themed Modal with Custom Text
Customize modal appearance using modalTheme.
π Persistent License (No Daily Recheck)
This skips license verification after the first success, unless storage is cleared.
π Redirect Instead of Modal on Failure
When license is invalid, users are redirected instead of seeing a modal.
π Injectables Support (Advanced Usage)
This sends retrieved injectables (if any) to your backend for secure use.
π‘ Tip: You can name your global config variable anything β the SDK will automatically detect it as long as it contains a
licenseorlkproperty. This helps you keep the SDK integration hidden or embedded in an existing namespace.
π§ Examples of custom config variable names
The SDK will scan all global variables at runtime and automatically use the first object that has a valid license or lk key. No additional configuration is needed.
π¦ Usage in Frameworks (ESM / CommonJS)
β€ ESM (e.g. Vite, Nuxt, React, etc.)
β€ CommonJS (e.g. Webpack, Next.js)
π How It Works
β Automatically detects the license key from any global variable on the
windowscope.π Verifies the license against the DevPayr API in real-time.
π§ Caches successful license checks using
localStorage(with support forrecheck: false).π« If the license is invalid:
Shows a modal with customizable text and theme (
modalText,modalTheme), orRedirects the user if
invalidBehavior: 'redirect'is set.
π If
injectablesare enabled:They are securely forwarded to your backend using the provided
injectablesEndpoint.
The SDK runs autonomously after being included β no need to manually call any methods.
π‘ Notes
π§© The global config key can be named anything (e.g.,
window.myapp,window.licenseSettings, etc.). The SDK will automatically find the first object with alicenseorlkproperty.π« The SDK only runs once and gracefully exits if license validation fails. Whenever an error is encountered, it will display the modal
π You can enable
debug: truein your config to see detailed logs in the browser console.
Last updated