In this document, you’ll learn what loaders are in Medusa.
A loader is a script that runs when the Medusa backend starts. The Medusa backend uses loaders to initialize the database connection, load plugins, register resources in the dependency container, and more.
src/loaders directory, then transpiled using the
build command into the
For example, the Redis Event Bus module uses a loader to establish a connection with Redis and log a message in the console.
Another example is the Algolia plugin, which uses a loader to update the index settings when the Medusa backend starts based on the plugin’s options.
Loaders can be used to access the dependency container and register custom resources in it.
Loaders can also be used to create scheduled jobs that run at a specified interval of time.
Developers can create a loader with the desired functionality directly within the Medusa Core, in a plugin, or in a module.
Learn how to create a loader.