Next.js
Next.js applications on monolayer
This section describes the integration of Next.js applications on monolayer, including supported platform capabilities.
Introduction to Next.js on monolayer
Next.js is a full-stack React framework that compiles and runs server-side and client-side code. When you deploy a Next.js application, monolayer automatically configures and provisions all required Amazon Web Services (AWS) resources without requiring manual infrastructure setup.
Next.js Platform Capabilities
Your Next.js application has native access to all built-in monolayer platform capabilities. These capabilities are fully managed and run securely within your AWS account.
You can use those capabilities using the monolayer SDK.
Managed PostgreSQL Database
monolayer automatically provisions a fully managed PostgreSQL database connected directly to your Next.js application.
- Automatic provisioning. monolayer configures a PostgreSQL database instance in your cloud environment.
- Connection injection. The system injects secure connection details into your application environment variables using the monolayer SDK.
- Zero-ops database. You do not need to configure VPCs, security groups, or database credentials manually.
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 Next.js 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_Asynchronous Background Tasks
You can process long-running background tasks asynchronously using the monolayer SDK.
- Offloaded processing. You can offload heavy calculations or secondary workloads from your main web request thread.
- Event-driven triggers. You can trigger background workflows in response to actions in your user interface.
Real-Time Communications
Your application can enable real-time, bi-directional web communications.
- WebSocket connections. monolayer manages the real-time WebSocket connection infrastructure.
- Direct SDK access. You can send and receive real-time messages directly using the monolayer SDK.
Scheduled Cron Jobs
You can define recurring commands in a root Procfile.
- Procfile scheduling. Define a process name that starts with
cron-, followed by a quotedSCHEDULEvalue and the command to run. - Managed trigger infrastructure. monolayer configures AWS event rules to run your command on schedule in Amazon Elastic Container Service (Amazon ECS).
Cron definitions in workload files aren't deployed. For syntax and examples, see Procfile cron processes.
Object Storage with Buckets
monolayer provides fully managed, S3-backed object storage for storing files, images, and other media.
- Simple SDK methods. Youcan define buckets wit hthe monolayer SDK and use the AWS SDK to upload and download objects.
- Scoped IAM access. monolayer configures secure AWS Identity and Access Management (IAM) permissions so your application only has access to its own bucket.