đź’» Next.js Infrastructure
The next.ts
file deploys Next.js applications using the Nextjs component from SST (opens in a new tab).
It configures both the main SaaS application and a separate landing page, setting up custom domains, environment variables, and necessary permissions.
Nextjs Component
The Nextjs
component from SST simplifies the deployment of Next.js applications by handling the build and deployment process, and optionally configuring a custom domain.
It integrates seamlessly with AWS services, providing a robust and scalable solution for hosting server-side rendered (SSR) and static sites, without having to use expensive services like Vercel.
Under the hood, it uses open-next (opens in a new tab) to build and deploy the Next.js apps in a similar fashion to Vercel (which, by the way, also uses AWS in the background).
Environment Variables
We link a long list of our previously defined environment variables to the Next.js application.
Custom Domains
WE also set up custom domains for both the landing page and the main application. The domains are configured based on the deployment stage (e.g., production, staging, dev).
Permissions and Linkings
The main application is given permissions to use the primary DynamoDB table, the bucket for file uploads, and for sending emails. These resources are linked to the application to ensure it has the necessary access.