Templates Overview
Templates are installable application bundles that combine Next.js pages, serverless scripts, and API resources into a single deployable package. Templates enable developers to distribute complete, customizable solutions on the marketplace with automatic subdomain deployment and dependency management.
What are Templates?
Templates provide a distribution mechanism for complete applications on the Mirra marketplace. Each template bundles a Next.js frontend, serverless backend scripts, and external API integrations into a single installable package that users can deploy with customization.
When a user installs a template, the platform performs several operations: validates dependencies, deploys scripts to the Mirra platform, builds and uploads the Next.js page to a CDN, assigns a unique subdomain, and applies user customization. The result is a fully functional application accessible at template-name.username.getmirra.app.
Syntax
Creating a Template
Template Structure
Template Components
Templates consist of three primary components that work together to create complete applications.
Page
pageA Next.js page component that serves as the template's user interface. Pages are built, optimized, and deployed to a CDN with automatic subdomain assignment.
Pages support React Server Components, client-side interactivity, and the full Next.js App Router feature set.
Scripts
scriptsServerless functions that provide backend logic, data processing, and API integrations. Scripts are deployed to the Mirra platform and can be invoked by the page or triggered by events.
Resources
resourcesReferences to marketplace resources that the template depends on. Resources can be required (installation fails without them) or optional (enhanced functionality when available).
During installation, the platform automatically installs required resources and prompts for optional ones.
Repository Structure
Templates are stored in Git repositories with a standardized directory structure:
The template.json file defines the template configuration, including name, version, dependencies, and customization options. The page.tsx file serves as the Next.js page entry point.
See a complete working example at github.com/Oz-Networks/mirra-sdk/tree/main/templates/example-template
When to Use Templates
Templates are ideal for:
- Complete Applications - Distribute full-stack applications with frontend and backend
- Marketplace Distribution - Publish and monetize complete solutions
- Customizable Solutions - Allow users to personalize branding and features
- Multi-Component Systems - Bundle pages, scripts, and resources together
- Subdomain Deployment - Provide users with dedicated URLs for their installations
Templates abstract away deployment complexity, allowing users to install and customize applications without managing infrastructure.
Customization
Templates support user customization through configurable fields. Customization enables users to personalize branding, behavior, and feature flags without modifying code.
Customization Field Types
Color
Number
Boolean
String
Select
Customization values are injected into the template at installation time and accessible in both page components and scripts through environment variables.
Next Steps
- Endpoints - Complete API reference for all template operations
- Examples - Practical template implementations
- Technical Notes - Build process, versioning, and troubleshooting
See Also
- Scripts - Serverless functions for template backend logic
- Resources - API integrations for template functionality
- Example Template Repository - Reference implementation