@getsupertab/supertab-js
v3.58.0
Published
Supertab.js: Supertab browser SDK with TypeScript support
Downloads
852
Maintainers
Readme
Supertab.js
This package allows Supertab.js to be imported as an ES module. It includes TypeScript declarations.
Installation
Install Supertab.js from npm::
npm install @getsupertab/supertab-jsImport, load and initialize the client in your application:
import { loadSupertab } from "@getsupertab/supertab-js";
(async () => {
const { Supertab } = await loadSupertab();
const supertabClient = new Supertab({ clientId: "test_client.X" });
})();loadSupertab() loads the latest compatible Supertab.js version from our CDN. It must be called in a browser environment—it won't work server-side.
Usage Example
import { loadSupertab } from "@getsupertab/supertab-js";
(async () => {
const { Supertab } = await loadSupertab();
const supertabClient = new Supertab({
clientId: "client.xyz",
});
const { show } = await supertabClient.createPaywall({
experienceId: "experience.xyz",
});
const paywallResult = await show();
console.log(paywallResult);
})();This example loads Supertab and creates a new Supertab.js instance using the new Supertab() constructor.
Then, the createPaywall method is used to create a new paywall.
The show function renders the paywall. Finally, once the user has completed or cancelled the purchase,
we print the result data to the browser console.
We've put a placeholder client ID and experience ID in this example. Replace them with your actual IDs to test this code with your Supertab.js merchant account. Each experience has a corresponding client ID and experience ID. You can find them in the Supertab Business Portal under "Experiences" -> Pencil icon (edit) -> "Installation" -> "Code Snippet".
Dependencies
All dependencies in this package are listed under devDependencies in package.json. This is because:
- The repository bundles all dependencies into the build output
- Consumers only need the built files from e.g.
dist/pkg/prod - No external dependencies are required at runtime
- The reason for bundling all dependencies (even with the npm package) is to avoid dependency conflicts with the consuming app.
Note: This package does not include an engines field in package.json because Node.js is only required for building the package, not for consuming it. The published npm package contains pre-built JavaScript bundles that run in the browser, so Node.js is a build detail, not a runtime requirement.
