Get Started With OpenNext
Get started with OpenNext on Azion: create or adapt a Next.js app, configure caching and storage for ISR/SSG, develop locally with the Azion CLI, and deploy to production.
The @aziontech/opennextjs-azion adapter lets you deploy Next.js apps to Azion Web Platform. This guide will help you set up a new or existing Next.js project for Azion, configure caching, develop locally, and deploy to production.
Prerequisites
Creating a New Next.js App
To create a new Next.js app pre-configured for Azion:
Or use a starter template:
Existing Next.js Apps
- Install the Azion Adapter:
- Configure
open-next.config.ts:
Create or update open-next.config.ts in your project root. Example:
- Update
tsconfig.json:
Your tsconfig.json must include: json "moduleResolution": "bundler" . This is required for correct build and runtime behavior.
If you encounter issues with ESM or open-next.config.ts, you may need to add:
See Known Issues for more details.
- Azion CLI Build and Deploy:
azion build: Builds your app for Azion.azion preview: Runs a local preview using Azion CLI.azion deploy: Deploys to Azion Web Platform using Remote Deployment.- or
azion deploy --localto deploy to Azion Web Platform using Local Deployment.
- or
- Set Up Caching and Storage:
Example Azion config:
Properties:
| Property | Type | Description |
|---|---|---|
| name | string | Name of the cache configuration. |
| stale? | boolean | Whether to allow stale content. |
| queryStringSort? | boolean | Whether to sort query string parameters. |
| methods? | CacheMethods | HTTP methods to cache. |
| post? | boolean | Whether to cache POST requests. |
| options? | boolean | Whether to cache OPTIONS requests. |
| browser? | BrowserCacheConfig | Browser cache settings. |
| browser.maxAgeSeconds | number | string | Maximum age for browser cache in seconds. |
| edge? | EdgeCacheConfig | Cache settings. |
| edge.maxAgeSeconds | number | string | Maximum age for cache in seconds. |
| cacheByCookie? | CacheByCookieConfig | Cache by cookie settings. |
| cacheByCookie.option | ’ignore’ | ‘varies’ | ‘whitelist’ | ‘blacklist’ | Cache by cookie option. |
| cacheByCookie.list? | string[] | List of cookies to use for caching. |
| cacheByQueryString? | CacheByQueryStringConfig | Cache by query string settings. |
| cacheByQueryString.option | ’ignore’ | ‘varies’ | ‘whitelist’ | ‘blacklist’ | Cache by query string option. |
| cacheByQueryString.list? | string[] | List of query string parameters to use for caching. |
Local Development
Use the Azion CLI for local development:
This runs your Application locally, simulating the Azion platform. See Troubleshooting for tips on debugging and log monitoring.
Deployment
Deploy your app to Azion Web Platform:
Or use the Azion CLI to deploy to Azion Web Platform using local deployment:
Best Practices & Troubleshooting
- See Known Issues for important config notes.
- See Troubleshooting for local dev, logging, and debugging tips.
- Explore Examples for starter projects and templates.
- For advanced caching, see Caching.