Package Installation
Install the SDK using your preferred package manager:System Requirements
Before installing, ensure your environment meets these requirements:Runtime Requirements
- Node.js: Version 16.x or higher (for development)
- Browser Support: Modern browsers with ES2015+ support
- TypeScript: Version 5.0 or higher (if using TypeScript)
Required Browser APIs
The SDK requires the following browser APIs:- Fetch API: For loading popup definitions from the server
- SessionStorage: For managing exit popup queue
- DOM APIs: For rendering and managing popup UI
- History API: For detecting route changes and exit triggers
The SDK automatically falls back to a no-op renderer in non-browser environments (like SSR), so it’s safe to import in universal JavaScript applications.
TypeScript Configuration
The SDK is written in TypeScript and includes type definitions out of the box. No additional type packages are required.tsconfig.json Setup
Ensure yourtsconfig.json includes these settings for optimal compatibility:
tsconfig.json
Type Imports
The SDK exports all necessary types for full TypeScript support:Framework-Specific Installation
React / Next.js
For React applications, you can initialize the SDK in auseEffect hook:
React Example
Vue.js
For Vue applications, initialize in themounted lifecycle hook:
Vue Example
Vanilla JavaScript
For plain JavaScript projects:Environment Variables
For security and flexibility, store your API key in environment variables:The API key is a public key that’s safe to expose in client-side code. It’s used to fetch popup definitions from the Deepdots API.
API Endpoints
The SDK connects to different API endpoints based on thenodeEnv configuration:
| Environment | API Base URL |
|---|---|
production | https://api.deepdots.com |
development | https://api-dev.deepdots.com |
Verification
To verify the installation is successful, add debug mode and check the console:Console Output
Troubleshooting
Module not found error
Module not found error
Ensure the package is properly installed by running
npm install @magicfeedback/popup-sdk again. Check that your node_modules folder contains the package.TypeScript type errors
TypeScript type errors
Make sure your
tsconfig.json includes "esModuleInterop": true and that you’re using TypeScript 5.0 or higher.SSR errors in Next.js
SSR errors in Next.js
Always wrap SDK initialization in a
typeof window !== 'undefined' check or use dynamic imports with { ssr: false }.API connection fails
API connection fails
Verify your API key is correct and that you’re using the appropriate
nodeEnv setting. Check browser network tab for failed requests.Next Steps
Quickstart Guide
Learn how to create your first popup with a complete working example