🧷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 license or lk property. 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 window scope.

  • πŸ” Verifies the license against the DevPayr API in real-time.

  • 🧠 Caches successful license checks using localStorage (with support for recheck: false).

  • 🚫 If the license is invalid:

    • Shows a modal with customizable text and theme (modalText, modalTheme), or

    • Redirects the user if invalidBehavior: 'redirect' is set.

  • πŸ” If injectables are 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 a license or lk property.

  • 🚫 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: true in your config to see detailed logs in the browser console.

Last updated