Integrate SDK with React - Tips Needed

By jonsdev 52 replies • 201 views • 2 hours ago

Initial Post

I'm trying to integrate the EzenIIa SDK into a React project but am running into dependency issues. I used `npm install @ezen/sdk`, but getting a Module Not Found error when importing. Any suggestions or examples of how to properly setup the SDK with Create React App?


// index.js
import { EzenClient } from '@ezen/sdk';

const client = new ezenClient({
  apiKey: 'my-api-key',
  env: 'sandbox'
});

client.init(); // Uncaught Module Error

mike

3 hours ago

Try using "ezen-init" CLI tool first. It adds needed Babel plugins:

npx ezen-init config <your-project>

Also make sure you have these in your webpack / vite config:

{ resolve: { alias: { 'ezen-sdk': path.resolve(__dirname, 'node_modules/@ezen/sdk/bundle') } } } }
A

alex

84 minutes ago

Another solution: try the CDN setup for React:

<script type="module"> import { Ezen } from 'https://cdn.ezenia.com/sdk/v1/index.js'; const instance = ezen.init({ apiKey: '...'}); </script>

This avoids some NPM module path issues completely

B

ben

50 minutes ago

For React 18+, add this to your tsconfig.json:

{ "compilerOptions": { "types": ["node", "@ezen/sdk", "react"] } }

Leave a Reply