If you're working with Directus, the open-source headless CMS and data platform, then Directus.js is your new best friend.
Directus.js is the official JavaScript SDK for interacting with Directus APIs. It offers a type-safe, modular, and fully composable interface for:
- Authenticating users
- Fetching data via REST or GraphQL
- Subscribing to real-time updates
- Managing files and content
✅ Why use Directus.js?
- Written in TypeScript – get autocompletion and strong types
- Supports REST and GraphQL out of the box
- Built with a composable architecture – import only what you need
- Works in both browser and Node.js environments
- Makes authentication and token management a breeze
🧪 Example
import { createDirectus, rest, readItems } from '@directus/sdk';
const directus = createDirectus('https://your-directus-url.com').with(rest());
const articles = await directus.request(readItems('articles'));
console.log(articles);
🛠️ Installation
npm install @directus/sdk
Or use Yarn:
yarn add @directus/sdk
🔗 Want to dive deeper?
Check out the full documentation at https://docs.directus.io/reference/sdk/
Top comments (0)