Plugin Development Overview RESTHeart
What Are Plugins?
RESTHeart is ready to go as soon as you install and configure it, with comprehensive MongoDB API and security functionality built-in. For many standard web applications, these basic features are sufficient.
These functionalities are provided by standard plugins distributed with RESTHeart in the ./plugins directory:
plugins
├── lib/ # Plugin dependencies
├── restheart-graphql.jar # GraphQL API
├── restheart-metrics.jar # Metrics and monitoring
├── restheart-mongoclient-provider.jar # MongoDB connection
├── restheart-mongodb.jar # REST API for MongoDB
├── restheart-polyglot.jar # JavaScript/TypeScript support
└── restheart-security.jar # Authentication & Authorization
Developing custom plugins is how you extend RESTHeart with your own business logic. You can develop plugins in Java, Kotlin, or JavaScript.
Plugin Types
RESTHeart supports 4 types of plugins, each serving a specific purpose:
| Type | Purpose | Example Use Cases |
|---|---|---|
Services |
Add web endpoints to handle HTTP requests |
REST APIs, GraphQL endpoints, file uploads, custom business logic |
Interceptors |
Monitor and modify requests/responses at different lifecycle stages |
Logging, validation, data transformation, adding headers |
Initializers |
Execute initialization logic at startup |
Database setup, loading reference data, starting background tasks |
Providers |
Supply objects to other plugins via dependency injection |
Database connections, shared utilities, configuration objects |
|
Tip
|
You can also extend the security layer with specialized security plugins. See Authentication Mechanisms, Authenticators, Authorizers, and Token Managers. |
Learning Path
We recommend learning plugin development in this order:
-
Start here: Plugin Development Tutorial - Build your first plugin step-by-step
-
Understand the basics: This page (you are here) - Core concepts and setup
-
Deep dive by type:
-
Services - Build web endpoints
-
Interceptors - Modify request/response flow
-
Initializers - Startup initialization
-
Providers - Dependency injection
-
-
Deploy: Deploy Plugins - Package and deploy your plugins
-
Advanced: JavaScript Plugins - Use JavaScript/TypeScript
Quick Start: Plugin Skeleton
The fastest way to start is with our plugin skeleton project:
$ git clone --depth 1 git@github.com:SoftInstigate/restheart-plugin-skeleton.git
$ cd restheart-plugin-skeleton
$ ./mvnw clean package
$ docker run --rm -p 8080:8080 -v ./target:/opt/restheart/plugins/custom softinstigate/restheart -s
Test the example service:
$ curl localhost:8080/srv
{"message":"Hello World!","rnd":"njXZksfKFW"}
|
Tip
|
Check the skeleton repository README and browse the official plugin examples for more code samples. |
Understanding Plugin Development
Before diving into building plugins, you should understand some core concepts:
Essential concepts (recommended for all developers):
-
@RegisterPlugin annotation - How RESTHeart discovers and configures your plugin
-
Configuration - How to configure plugins via
restheart.yml -
Dependency Injection - How to access MongoDB, configuration, and other services
-
Request/Response Types - Understanding type safety and content handling
➡️ Read: Plugin Core Concepts
When you’re ready to code:
-
Start with Plugin Development Tutorial for hands-on practice
-
Then explore specific plugin types: Services, Interceptors, Initializers, Providers
Next Steps
Now that you understand the basics, follow this learning path:
-
Understand the concepts: Core Concepts - Essential knowledge before coding
-
Hands-on practice: Complete the Plugin Development Tutorial to build your first working plugin
-
Learn each plugin type:
-
Services - Create REST endpoints
-
Interceptors - Modify request/response flow
-
Initializers - Run startup logic
-
Providers - Create injectable dependencies
-
-
Deploy your plugins: Deployment Guide
-
Explore examples: Browse official examples on GitHub
Reference
-
API Documentation: restheart-commons Javadoc
-
Plugin Examples: GitHub repository
-
Skeleton Project: Plugin skeleton on GitHub EOF cat > /tmp/overview_end.txt << 'EOF'
The only required dependency to develop a plugin is restheart-commons.
With maven: