
Product
Socket MCP Adds Org Alerts, Threat Feed Review, and Package Inspection
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.
@universal-data-layer/plugin-source-contentful
Advanced tools
Contentful source plugin for Universal Data Layer
Contentful source plugin for Universal Data Layer. Automatically sources all content types, entries, and assets from a Contentful space.
npm install @universal-data-layer/plugin-source-contentful
Add the plugin to your UDL configuration:
// udl.config.ts
import { defineConfig } from 'universal-data-layer';
export const config = defineConfig({
plugins: [
{
name: '@universal-data-layer/plugin-source-contentful',
options: {
spaceId: process.env['CONTENTFUL_SPACE_ID'],
accessToken: process.env['CONTENTFUL_ACCESS_TOKEN'],
},
},
],
});
| Option | Type | Default | Description |
|---|---|---|---|
spaceId | string | required | Your Contentful space ID |
accessToken | string | required | Contentful Delivery API access token |
locale | string | 'en-US' | Locale to extract from field values |
host | string | 'cdn.contentful.com' | API host. Use 'preview.contentful.com' for draft content |
environment | string | 'master' | Contentful environment |
nodePrefix | string | 'Contentful' | Prefix for generated node type names |
downloadAssets | boolean | false | Whether to download assets locally (not yet implemented) |
contentTypeFilter | (ct: ContentType) => boolean | - | Filter which content types to source |
useNameForId | boolean | true | Use content type name (vs ID) for node type names |
forceFullSync | boolean | false | Force full sync, ignoring stored sync token |
syncTokenStorage | SyncTokenStorage | file-based | Custom storage for sync tokens |
The plugin generates node types based on your Contentful content types:
{nodePrefix}{ContentTypeName} (e.g., ContentfulBlogPost, ContentfulAuthor){nodePrefix}Asset (e.g., ContentfulAsset)Each node includes:
contentfulId - Original Contentful sys.id (indexed for lookups)sys - Contentful system metadata (createdAt, updatedAt, revision, etc.)The plugin uses Contentful's Sync API for efficient incremental updates:
Sync tokens are stored in .udl/cache/contentful-sync-tokens.json by default. You can provide custom storage:
{
name: '@universal-data-layer/plugin-source-contentful',
options: {
spaceId: '...',
accessToken: '...',
locale: 'en-US',
syncTokenStorage: {
async getSyncToken(key) {
// Return stored token or null
},
async setSyncToken(key, token) {
// Store the token
},
async clearSyncToken(key) {
// Clear the token (optional)
},
},
},
}
To fetch draft/unpublished content, use the Preview API:
{
name: '@universal-data-layer/plugin-source-contentful',
options: {
spaceId: process.env['CONTENTFUL_SPACE_ID'],
accessToken: process.env['CONTENTFUL_PREVIEW_TOKEN'],
locale: 'en-US',
host: 'preview.contentful.com',
},
}
Use nodePrefix to source from multiple Contentful spaces:
export const config = defineConfig({
plugins: [
{
name: '@universal-data-layer/plugin-source-contentful',
options: {
spaceId: process.env['CMS_SPACE_ID'],
accessToken: process.env['CMS_ACCESS_TOKEN'],
locale: 'en-US',
nodePrefix: 'CMS',
},
},
{
name: '@universal-data-layer/plugin-source-contentful',
options: {
spaceId: process.env['CRM_SPACE_ID'],
accessToken: process.env['CRM_ACCESS_TOKEN'],
locale: 'en-US',
nodePrefix: 'CRM',
},
},
],
});
This generates separate node types: CMSBlogPost, CRMCustomer, etc.
Filter which content types to source:
{
name: '@universal-data-layer/plugin-source-contentful',
options: {
spaceId: '...',
accessToken: '...',
locale: 'en-US',
contentTypeFilter: (contentType) => {
// Only source 'blogPost' and 'author' content types
return ['blogPost', 'author'].includes(contentType.sys.id);
},
},
}
Linked entries and assets are stored as references with their Contentful ID:
{
_contentfulRef: true,
contentfulId: 'abc123',
linkType: 'Entry' | 'Asset',
}
Use the contentfulId index to resolve references at query time.
Rich text fields are stored with the raw JSON structure and extracted references:
{
raw: { /* Contentful rich text document */ },
references: [
{ _contentfulRef: true, contentfulId: '...', linkType: 'Entry' },
{ _contentfulRef: true, contentfulId: '...', linkType: 'Asset' },
],
}
The plugin exports error classes for specific error handling:
import {
ContentfulConfigError,
ContentfulApiError,
ContentfulSyncError,
isRateLimitError,
isAuthError,
} from '@universal-data-layer/plugin-source-contentful';
try {
// ...
} catch (error) {
if (isRateLimitError(error)) {
// Handle rate limiting
}
if (isAuthError(error)) {
// Handle authentication errors
}
}
MIT
FAQs
Contentful source plugin for Universal Data Layer
The npm package @universal-data-layer/plugin-source-contentful receives a total of 28 weekly downloads. As such, @universal-data-layer/plugin-source-contentful popularity was classified as not popular.
We found that @universal-data-layer/plugin-source-contentful demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.

Research
More than 140 Mastra npm packages were compromised in a supply chain attack that used a typosquatted dependency to deliver a cross-platform infostealer during installation.