LoopBack components are predefined packages that extend a basic LoopBack application. Fundamentally, a component is related code bundled together as a unit to enable LoopBack applications for easy reuse. You can configure components declaratively in
The bare minimum to meet the LoopBack component "contract" is to export a
function(app, options) as the main module export.
A LoopBack application itself is nothing more than a grouping of components with elements to tie them all together.
To be a LoopBack component, a module must export a function with the following signature as the main module export:Compare that with Express middleware, which exports
function(options)that is supposed to return
function(req, res, next)or
function(err, req, res, next).
Pre-defined LoopBack components
LoopBack provides several pre-defined components, as described in the table below.
The sections below describe the configuration settings for each component in
|API Explorer||Enables the Swagger UI for the API. See Use API Explorer for an example.||loopback-component-explorer|
|OAuth 2.0||Enables LoopBack applications to function as oAuth 2.0 providers to authenticate and authorize client applications and users to access protected API endpoints.||loopback-component-oauth2|
|Adds push notification capabilities to your LoopBack application as a mobile back end service.|
|Storage component||Adds an interface to abstract storage providers like S3, filesystem into general containers and files.||loopback-component-storage|
|Synchronization||Adds replication capability between LoopBack running in a browser or between LoopBack back-end instances to enable offline synchronization and server-to-server data synchronization.|
Built into LoopBack; will be refactored into loopback-component-sync
|Third-party login (Passport)||Adds third-party login capabilities to your LoopBack application like Facebook, GitHub etc.||loopback-component-passport|