The `microcms-js-sdk` is the official JavaScript SDK client designed to interact with microCMS Content APIs and Management APIs from both Node.js and browser environments. Currently at stable version `3.4.0`, it receives regular updates, with several minor and patch releases in recent months, alongside a significant major update to v3.0.0. Key differentiators include its comprehensive support for microCMS's List and Object API formats, methods for common operations like content retrieval (`getList`, `getListDetail`, `getObject`), content creation, updating, and deletion. It also offers features like `getAllContents` and `getAllContentIds` for advanced retrieval patterns and a Management API client for tasks such as image uploads (introduced in v3.1.0). The SDK is type-safe as it ships with TypeScript definitions, making it suitable for modern JavaScript and TypeScript projects. Users should be aware of the breaking changes introduced in v3.0.0, particularly the shift to `global fetch` and a Node.js v18+ runtime requirement.
npm install microcms-js-sdkVerified import paths — ran on the pinned version, not inferred.
This quickstart initializes the microCMS client and fetches a paginated list of blog content, demonstrating querying with filters and field selection. It includes basic TypeScript typing for the content structure.
Ensure your environment (Node.js >=18 or modern browser) supports the native `fetch` API. Remove any usage of the `customFetch` option or `cross-fetch` polyfills managed by the SDK. If `fetch` is not globally available in your Node.js environment, consider a dedicated polyfill at your application's entry point.
Upgrade your Node.js runtime to version 18.0.0 or newer. Check your `package.json` engines field and CI/CD environments to ensure compatibility.
No direct code changes are typically required unless you were relying on specific `qs` serialization quirks. Ensure all query parameters adhere to `URLSearchParams` compatibility, especially for array or nested object serialization.
Update `microcms-js-sdk` to version `3.4.0` or later using `npm update microcms-js-sdk` or `yarn upgrade microcms-js-sdk`.
For production applications, download the `microcms-js-sdk.js` UMD bundle from the GitHub releases page and host it on your own server or content delivery network instead of relying on third-party CDNs.
Upgrade your Node.js version to 18.0.0 or higher. Alternatively, if upgrading is not immediately possible, you may need to explicitly polyfill `fetch` globally in your application's entry point, though this is not officially supported by the SDK maintainers for v3+.
Verify that `createClient` is imported correctly based on your module system (ESM `import` for modern Node.js/bundlers, CommonJS `require` for older Node.js, or `microcms.createClient` for browser UMD). Ensure `createClient` is called and its result is assigned to a variable (`client`) before attempting to use `client.getList` or other methods.
Ensure that `serviceDomain` and `apiKey` are correctly provided as strings when initializing the client. Double-check environment variable names and fallback values. For example: `serviceDomain: process.env.MICROCMS_SERVICE_DOMAIN || 'your_domain'`.
No dependency data recorded yet.