Installation
Installing Astro Maintenance
Section titled “Installing Astro Maintenance”Adding the maintenance page integration to your Astro project is straightforward. Follow these steps to get started quickly.
Installation
Section titled “Installation”Astro includes an astro add
command to automate the setup of official integrations. If you prefer, you can install integrations manually instead.
To install astro-maintenance
, run the following from your project directory and follow the prompts:
# npmnpm astro add astro-maintenance
# pnpmpnpm astro add astro-maintenance
# yarnyarn astro add astro-maintenance
If you run into any issues, feel free to report them to us on GitHub and try the manual installation steps below.
Manual Install
Section titled “Manual Install”First, install the astro-maintenance
package:
# npmnpm install astro-maintenance
# pnpmpnpm add astro-maintenance
# yarnyarn add astro-maintenance
Then, apply the integration to your astro.config.*
file using the integrations
property:
import { defineConfig } from 'astro/config';import maintenance from 'astro-maintenance';
export default defineConfig({ // ... integrations: [ maintenance({ // your configuration options enabled: true, }), ],});
Basic Setup
Section titled “Basic Setup”Once installed, you need to add the integration to your Astro configuration file:
import { defineConfig } from "astro/config";import maintenance from "astro-maintenance";
export default defineConfig({ integrations: [ maintenance({ // Maintenance mode is enabled by default template: "simple", // Options: 'simple', 'countdown', 'construction' or path to custom template title: "Site Under Maintenance", description: "We are performing scheduled maintenance. Please check back soon.", // Other optional parameters... }), ],});
Verifying the Installation
Section titled “Verifying the Installation”After configuring the integration, you can verify that it’s working by:
- Setting
enabled: true
in your configuration - Starting your development server or building your site
- Visiting your site - you should see the maintenance page
Temporarily Bypassing Maintenance Mode
Section titled “Temporarily Bypassing Maintenance Mode”If you need to view your site while maintenance mode is active, you can use the override
parameter:
maintenance({ // ... other options override: "preview" // Add this option})
Then access your site by adding ?preview
to the URL, for example:
http://localhost:3000/?preview
Using Environment Variables
Section titled “Using Environment Variables”You can also configure Astro Maintenance using environment variables, which is especially useful for deployment environments where you want to toggle maintenance mode without changing code or rebuilding your application.
Environment variables always take precedence over programmatically defined options. Simply prefix any option with MAINTENANCE_
(in uppercase) to set it via environment variable:
# .env file or environment variablesMAINTENANCE_ENABLED=trueMAINTENANCE_TITLE="We're performing maintenance"MAINTENANCE_TEMPLATE="countdown"MAINTENANCE_COUNTDOWN="2025-12-31T23:59:59"
This makes it easy to:
- Toggle maintenance mode in production without code changes
- Set different configurations for different environments
- Control maintenance mode in CI/CD pipelines
For a complete list of supported environment variables, see the Configuration Options page.
💡 Security Tip For security reasons, avoid using a simple or guessable override key like
"preview"
. Instead, use a long, randomly generated, URI-safe string (e.g.,"bypass-43uhksdf82jd82"
) to reduce the risk of unintended access.
🔐 Generating a Secure Override Key
Section titled “🔐 Generating a Secure Override Key”You can use this command in your terminal to generate a safe random key:
node -e "console.log('bypass-' + require('crypto').randomBytes(12).toString('base64url'))"
Example output:
bypass-jK8dL2t3Y_mkNCxQ9r4Ctg
Use this value as your override
parameter:
maintenance({ // ... other options override: "bypass-jK8dL2t3Y_mkNCxQ9r4Ctg"})
Now you can access your site like this:
http://localhost:3000/?bypass-jK8dL2t3Y_mkNCxQ9r4Ctg
Next Steps
Section titled “Next Steps”Now that you’ve installed the integration, you can:
- Explore the Configuration Options to customize your maintenance page
- Learn about the different Templates available