About Facet

Your MongoDB API already works. Facet makes it speak HTML.

A Different Starting Point

Most web frameworks assume you start with the UI and add an API later. Facet inverts that. If your data is already in MongoDB and your API already works, adding HTML output is a presentation concern, not a new application. Facet treats it that way: a template is a view over data you already own, not a reason to restructure your backend.

Common Questions

What makes Facet different from Spring Boot or Java MVC frameworks?

Spring Boot is powerful but complex: controllers, services, repositories, configuration files, build tools, and dependency injection. Facet eliminates this boilerplate. Your MongoDB collections automatically become web pages through convention-based templates. No controllers. No ORMs. No XML. Just templates that map to your API structure. Get Java's performance without Java's ceremony.

What makes Facet different from Thymeleaf or Spring MVC?

Thymeleaf requires a controller for every page you add. That means writing Java code, wiring routes, and configuring models: more backend work, not less. With Facet, the template file is the only artifact you create. Place it in the right directory and the endpoint starts serving HTML. No Java code, no restart, no configuration change.

What makes Facet different from React or Next.js?

React and Next.js are powerful, but they introduce a separate build pipeline, a separate deployment, and a programming model that is fundamentally different from backend development. Facet does not require JavaScript knowledge. If you know your API structure and can write HTML templates, you already have everything you need.

What does "hybrid" mean?

The same endpoint serves both JSON and HTML based on the Accept header. Request /products from a browser (HTML) or from a mobile app (JSON), same code, same data but different representation. Templates are opt-in: add HTML rendering only where you need it. Your REST API remains unchanged. This enables progressive enhancement and islands architecture patterns naturally.

How does HTMX integration work?

Facet has native HTMX support built in. It automatically detects HTMX requests and renders fragment templates instead of full pages, no backend code needed. Build dynamic, SPA-like experiences with server-side rendering and zero JavaScript build tools. Your templates declare behavior; Facet handles the plumbing.

What's the developer experience like?

Hot reload templates without restart. No build step. No webpack, no npm scripts. Edit a template, refresh your browser, see changes instantly. Convention-based routing means you don't wire up routes manually. Path-based template resolution mirrors your API structure automatically. Focus on your application, not on framework configuration.

How do I extend Facet with custom logic?

Facet runs on RESTHeart, which supports plugins in both Java and JavaScript (via GraalVM). For most extensions, JavaScript plugins are the preferred choice: no compilation step, no container restart, just edit a .mjs file and the next request picks up the new code automatically, exactly like Pebble templates.

A JavaScript plugin is a single .mjs file paired with a package.json manifest. Drop the folder into the plugins/ directory, declare the service URI, and Facet's rendering pipeline handles the rest: the plugin's JSON response is automatically rendered as HTML using the matching template.

The Product Catalog example ships with a working JavaScript plugin (product-stats) that queries MongoDB and returns aggregated inventory statistics. The same endpoint serves raw JSON for API clients and an HTML dashboard for browsers, without a single line of Java. See the JavaScript Plugins guide for a step-by-step walkthrough.

Use Java plugins for complex integrations that need the full JVM ecosystem. Both types integrate seamlessly with Facet's template rendering pipeline.

What about performance?

Choose your runtime based on needs: GraalVM JDK for JavaScript extensibility (~1s startup, ~150MB memory) or native image for maximum performance (<100ms startup, ~50MB memory). Both handle thousands of concurrent requests efficiently. MongoDB queries stream directly to templates, no ORM overhead. Production-grade performance by default, not as an afterthought.

How do I deploy Facet?

Facet is a single JAR file or native binary, no application server needed. Deploy to Docker, Kubernetes, AWS, Azure, or bare metal. Stateless design means horizontal scaling is trivial. Native binaries don't require Java installation. Cloud-native by design: 12-factor compliant, environment-based configuration, health checks built in.

Ready to Get Started?

Learn how to build your first Facet application in 5 minutes