Skip to content

Commit 67419fa

Browse files
authored
Merge pull request #418 from contentstack/chore/DX-2902
chore: update README with import snippets
2 parents b68dd3f + 9b30b03 commit 67419fa

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

README.md

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,31 @@ Install it via npm:
1919
```bash
2020
npm i @contentstack/management
2121
```
22-
To import the SDK, use the following command:
23-
```javascript
24-
import contentstack from ‘@contentstack/management’
25-
26-
contentstackClient = contentstack.client()
27-
```
22+
To import the SDK, use one of the following ways :
23+
1. **JavaScript ES Modules**
24+
```javascript
25+
import contentstack from '@contentstack/management';
26+
```
27+
- Requires `"type": "module"` in package.json
28+
29+
2. **TypeScript with esModuleInterop**
30+
```typescript
31+
import contentstack from '@contentstack/management';
32+
```
33+
- Requires `"esModuleInterop": true` in tsconfig.json
34+
35+
3. **TypeScript Namespace Import**
36+
```typescript
37+
import * as contentstack from '@contentstack/management';
38+
```
39+
- Works regardless of esModuleInterop setting
40+
41+
4. **TypeScript Destructuring**
42+
```typescript
43+
import contentstack from '@contentstack/management';
44+
const { client } = contentstack;
45+
```
46+
- Access client function from default export
2847

2948
### Authentication
3049
To use this SDK, you need to authenticate your users by using the Authtoken, credentials, or Management Token (stack-level token).

0 commit comments

Comments
 (0)