monolayer Docs
monolayer Docs
Introduction

Getting Started

Install monolayer in your AWSAdd a GitHub App

User Guide

Platform

Supported FrameworksNext.jsReact RouterVite SPAsFastAPI
Deployment ArchitectureProcfile

Other

Feedbackmonolayer SDK Docsmonolayer.dev
Frameworks

React Router

React Router applications on monolayer

This section describes the integration of React Router applications on monolayer, including supported platform capabilities, automatic database detection, and custom launch configurations using a Procfile.

Introduction to React Router on monolayer

React Router is a flexible library and full-stack framework for React applications. monolayer provides robust support for React Router applications, featuring automatic configuration of database services and customizable launch environments.

When you deploy a React Router application, monolayer automatically builds your static assets and configures the runtime environment to serve your application efficiently.

React Router Platform Capabilities

Your React Router application has access to various platform capabilities. While some advanced integrations are currently under development, the core database and lifecycle functionalities are fully supported.

Managed PostgreSQL Database

monolayer automatically provisions a fully managed PostgreSQL database when it detects PostgreSQL usage in your React Router project.

  • Automatic detection. The system checks your project dependencies for PostgreSQL database drivers.
  • Database provisioning. Upon detection, monolayer provisions a PostgreSQL database in your AWS account.
  • Connection injection. monolayer injects secure database access details into your environment variables automatically, ensuring that no manual database configuration is needed.

Detection Conditions

monolayer automatically detects your database configuration when your project satisfies the following conditions:

  • Server-Side Rendering (SSR): Your React Router configuration must either omit the ssr option or set ssr: true.
  • Database dependencies: Your project must define either pg or postgres as a dependency in your package.json file.

When monolayer detects PostgreSQL usage, it automatically creates the following database lifecycle workloads:

  • Database creation (createDatabase):
    • If your package.json contains a db:create script, the workload runs db:create.
    • If db:create is missing but db:migrate exists, the workload runs db:migrate.
    • This lifecycle workload runs only once.
  • Database migrations (migrateDatabase):
    • If your package.json contains a db:migrate entry, the workload runs db:migrate.
    • This lifecycle workload runs before deploying the application.

Runtime Environment Variables

At runtime, monolayer automatically injects the following environment variables into your application environment:

  • DATABASE_URL: The full connection string used to connect to your PostgreSQL database.
  • PGPASSWORD: The secure password for database authentication.
  • PGUSER: The username for your database.
  • PGHOST: The endpoint host address of your database.
  • PGPORT: The port number used to connect to your database instance.
  • PGDATABASE: The name of your PostgreSQL database.

Application Lifecycle Workloads

You can execute custom scripts and tasks during specific phases of your deployment lifecycle. For more information on process configurations, see the Procfile Guide.

  • Deployment orchestration. You can run database migrations or prepare data using Procfile-managed commands before or after your web server starts.
  • Zero-ops environment. The platform coordinates the initialization of resources so your lifecycle scripts execute in the correct order.

For React Router applications, you can define custom processes in a root Procfile to run lifecycle workloads when deploying your application.

bootstrap: _your-command_
beforeRollout: _your-command_
afterRollout: _your-command_
createDatabase: _your-command_
migrateDatabase: _your-command_

Capabilities Roadmap

Support for the remaining monolayer platform capabilities is actively being developed. The following services will be available soon:

  • Asynchronous background tasks. Support for offloading background tasks and queuing work asynchronously is coming soon.
  • Real-time communications. Native real-time WebSocket support is coming soon.
  • Scheduled cron jobs. Running scheduled tasks using cron syntax is coming soon.
  • Object storage with buckets. Secure object storage backed by Amazon Simple Storage Service (Amazon S3) is coming soon.

Next.js

Next.js applications on monolayer

Vite SPAs

Vite SPAs on monolayer

On this page

Introduction to React Router on monolayerReact Router Platform CapabilitiesManaged PostgreSQL DatabaseDetection ConditionsRuntime Environment VariablesApplication Lifecycle WorkloadsCapabilities Roadmap