Plugins

Plugin System Overview

Learn about the Universal Data Layer plugin architecture

Overview

The Universal Data Layer uses a plugin-based architecture that allows you to extend functionality and connect to various data sources. Plugins are modular packages that can be configured, registered, and loaded at runtime.

How Plugins Work

Plugins in UDL follow a simple convention:

  1. Each plugin is a package (npm package or local directory) containing a udl.config.js file
  2. The config file exports plugin metadata and an optional onLoad lifecycle hook
  3. Plugins are registered in your application's udl.config.js file
  4. When the server starts, UDL loads and initializes all registered plugins

Plugin Types

Currently, UDL supports the following plugin types:

  • core: Core system plugins that provide foundational functionality
  • source: Data source plugins that connect to external APIs or services (e.g., Contentful, Shopify, Okendo)

Key Concepts

Plugin Configuration

Every plugin has a udl.config.js file at its root that exports:

  • config: Plugin metadata (name, version, type)
  • onLoad: Optional lifecycle hook that runs when the plugin is loaded

Lifecycle Hooks

The onLoad hook is called when a plugin is initialized. It receives a context object containing:

  • options: Plugin-specific options passed during registration
  • config: The application's UDL configuration

Plugin Resolution

UDL resolves plugins in the following order:

  1. Relative/absolute paths: If the plugin name starts with . or /, it's treated as a file path
  2. npm packages: Otherwise, UDL attempts to resolve it as an installed npm package
  3. Fallback: If resolution fails, UDL falls back to checking node_modules directly

Next Steps