Website with PayloadCMS Hosting for Free: A Static Astro Site on S3 + CloudFront

Nov 25, 202612 min read

A landing page with a blog is the textbook CMS use case. The default way to build one today — often scaffolded by an AI agent in a few minutes — is Next.js with Payload CMS, where Next.js renders pages by querying the CMS. It works, but with server rendering or incremental regeneration the CMS becomes part of the serving path: pages need a running server or serverless functions, plus a database that answers on every request or revalidation. You pay for, and operate, compute that re-renders content which changes a few times a week.

There is a different way to set this up. Editors use Payload CMS as usual, but visitors never touch it. The website is plain static files on Amazon S3 behind Amazon CloudFront, rebuilt by GitHub Actions when an editor clicks Publish. The only component that grows with traffic is the CDN.

This setup may cost nothing to host, and for a typical company website it is free in most cases. The conditions matter, so this post is explicit about them. Below is the architecture, the configuration for each piece, and where the free tier ends.

The examples use Payload with Astro, but the same pattern works with Payload and a statically exported Next.js site. The pages fetch CMS data at build time in either framework, and the deploy pipeline stays the same: only the build command and the output folder (out/ instead of dist/) change. We chose Astro for the website for two reasons:

  • Static output is the default. A Next.js static export works too, but it rules out features such as ISR, redirects, headers, Server Actions and the default image optimization loader, so you have to keep the app inside that subset.
  • No client-side JavaScript unless a component needs it. Astro renders pages to plain HTML and only hydrates components you mark as islands. A content page ships no framework runtime, so it is lighter to download and quicker to become usable than the same page with React hydration.

Why a CMS Website Ends Up Needing a Server

WordPress and Joomla made websites editable by non-developers. They also bundled content, rendering and hosting into one always-on PHP server, and their extensibility eventually ran out for more demanding projects. Commerce went through the same cycle: teams outgrew Shopify and WooCommerce and moved to composable engines like Medusa (we covered why technical teams choose Medusa).

Headless, code-first CMSs such as Payload split content from presentation. But the most common Next.js setup couples them again at runtime: the page server asks the CMS for data per request, or per revalidation window. The CMS and its database become part of the serving path.

AI agents make this setup easy to generate. They don't decide, unless you tell them, where rendering should happen and what must stay online for a visitor to see a page. That decision drives both the hosting bill and the operational burden.

Rendering Modes: What Must Be Online for a Visitor

ModeWhen HTML is producedWhat must be online for a visitTypical fit
SSR (dynamic)On every requestApp server + CMS/databasePersonalized or real-time pages
ISROn the first request after the revalidation windowApp server or functions + CMS/database during revalidationLarge catalogs, frequent changes
SSG (static)At build timeOnly the CDNContent that changes on an editorial schedule
CSRIn the browserAn API for every data fetchApp-like UIs, often behind login

A CMS outage doesn't have to take the website down with ISR either: if revalidation fails, Next.js keeps serving the last successfully generated page, as long as your data fetching throws on errors instead of rendering empty content. The difference with SSG is what still has to run. ISR needs an app server or functions for every visit; SSG needs only the CDN, which serves files and nothing else.

We covered these trade-offs in depth for Next.js in SSG, ISR, SSR, CSR: which strategy should I use, Next.js streaming vs CSR vs SSR and static and dynamic components with PPR. This post applies the static option to a CMS-driven site.

The Architecture

Architecture: visitors reach only CloudFront and S3; editors use Payload CMS on Amplify with Neon, and Publish triggers a GitHub Actions static build

ComponentRoleUsed when
Payload CMS 3 on AWS Amplify HostingAdmin UI, REST API, form submissionsEditor sessions, builds, form posts
Neon PostgresPayload's databaseOnly when the CMS handles a request
Astro (static output)The websiteBuild time only
S3 + CloudFrontServes HTML, assets and mediaEvery visit
GitHub ActionsBuilds and deploys the sitePublish click, push to site code

The CMS runs serverless on Amplify, so it only consumes compute while an editor is working, a build is reading content, or someone submits a form. If you want the CMS itself on Amplify step by step, see how to deploy Payload CMS on AWS Amplify for free.

Building the Site From the CMS at Build Time

Every page reads the Payload REST API during astro build and nowhere else. The fetch runs once, on the build machine, so the published site never depends on the CMS being up:

--- const CMS_URL = import.meta.env.CMS_URL const { slug } = Astro.props const res = await (await fetch(`${CMS_URL}/api/pages?where[slug][equals]=${slug}&depth=1`)).json() const page = res.docs[0] ---

Media: serve uploads from the CMS bucket

Payload already stores uploads in S3 through its storage adapter. Instead of copying images into every build, CloudFront serves /media/* straight from that bucket. Configure the adapter to write uploads under a media/ key prefix, because CloudFront forwards the full path (/media/photo.jpg) to the bucket. Images then never pass through the build or the CMS when a visitor loads them.

The Publish Button: Triggering GitHub Actions From Payload

Editors don't use Git. They click Publish in the Payload admin, which calls a custom endpoint. The endpoint starts the deploy workflow through the GitHub API's workflow_dispatch:

export const publishStart: Endpoint = { path: '/publishing/start', method: 'post', handler: async (req) => { if (!req.user) return Response.json({ error: 'Unauthorized' }, { status: 401 }) const res = await fetch( `https://api.github.com/repos/${process.env.GITHUB_REPO}/actions/workflows/deploy-web.yml/dispatches`, { method: 'POST', headers: { Accept: 'application/vnd.github+json', Authorization: `Bearer ${process.env.GITHUB_TOKEN}`, 'X-GitHub-Api-Version': '2022-11-28', }, body: JSON.stringify({ ref: 'main', inputs: { reason: `Published from CMS: ${req.user.email}` } }), }, ) if (!res.ok) return Response.json({ error: `GitHub rejected the request (${res.status})` }, { status: 502 }) return Response.json({ ok: true }) }, }

Register it in payload.config.ts under endpoints, and add a button component to the admin panel that POSTs to /api/publishing/start. GITHUB_TOKEN is a fine-grained token scoped to this one repository with Actions: write permission. It stays on the CMS server, never in the browser.

The Deploy Workflow

The whole workflow fits in one file. It runs when the CMS button dispatches it and when the site code changes:

name: deploy-web on: workflow_dispatch: inputs: reason: description: Why the site is rebuilt required: false push: branches: [main] paths: ['web/**', '.github/workflows/deploy-web.yml'] concurrency: group: deploy-web cancel-in-progress: false permissions: id-token: write contents: read jobs: deploy: runs-on: ubuntu-latest defaults: run: working-directory: web env: CMS_URL: ${{ vars.CMS_URL }} steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 22 cache: npm cache-dependency-path: web/package-lock.json - name: Check the CMS answers run: curl -fsS "$CMS_URL/api/globals/settings?depth=0" > /dev/null - run: npm ci - run: npm run build - uses: aws-actions/configure-aws-credentials@v4 with: role-to-assume: ${{ vars.AWS_ROLE_ARN }} aws-region: ${{ vars.AWS_REGION }} - name: Upload env: BUCKET: ${{ vars.SITE_BUCKET }} run: | # Hashed assets never change: cache for a year. aws s3 sync dist/_astro "s3://$BUCKET/_astro" --cache-control "public,max-age=31536000,immutable" # Pages and other files: browsers revalidate, CloudFront keeps them until the invalidation below. aws s3 sync dist "s3://$BUCKET" --delete --exclude "_astro/*" \ --cache-control "public,max-age=0,s-maxage=31536000,must-revalidate" - name: Invalidate CloudFront run: aws cloudfront create-invalidation --distribution-id "${{ vars.DISTRIBUTION_ID }}" --paths "/*"

A few lines carry most of the design:

  • cancel-in-progress: false lets a running deploy finish instead of cancelling it mid-upload. If more publishes arrive meanwhile, GitHub keeps only the newest pending run, which builds the latest content.
  • id-token: write lets the job assume an AWS role through OIDC, so no AWS keys are stored in GitHub. The role is defined in CDK below.
  • The CMS check fails the run before anything is uploaded if the CMS is unreachable, instead of publishing a half-empty site.
  • Two cache lifetimes. Astro's _astro/ files have content hashes in their names, so caching them for a year is safe. Everything else gets max-age=0 for browsers and s-maxage for CloudFront: browsers always ask the edge for the current page, and CloudFront serves it from cache without going back to S3.
  • The invalidation is what makes a publish visible, because CloudFront would otherwise keep the old pages. A /* invalidation counts as one path, and the first 1,000 paths each month are free.
  • --delete removes pages that were deleted in the CMS. It's safe because uploads live in the separate media bucket.

The Infrastructure as Code: AWS CDK

The S3 buckets, the CloudFront distribution and the deploy role are defined with the AWS Cloud Development Kit (CDK). CDK lets you describe AWS resources in TypeScript; cdk deploy turns that code into a CloudFormation stack and creates or updates the resources.

You could click the same setup together in the AWS console, but code works much better when an AI agent does the work. An agent can write and edit CDK code like any other code, show you exactly what will change with cdk diff before anything is deployed, and recreate the whole setup for a second site or environment. Console clicks leave nothing to review in a pull request and nothing to repeat.

CloudFront in front of S3

Both buckets stay private, and CloudFront reads them through Origin Access Control. rewrite is the CloudFront Function shown below; headers is a response headers policy with standard security headers:

const distribution = new cloudfront.Distribution(this, 'Cdn', { defaultRootObject: 'index.html', priceClass: cloudfront.PriceClass.PRICE_CLASS_100, httpVersion: cloudfront.HttpVersion.HTTP2_AND_3, defaultBehavior: { origin: origins.S3BucketOrigin.withOriginAccessControl(siteBucket), viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS, cachePolicy: cloudfront.CachePolicy.CACHING_OPTIMIZED, responseHeadersPolicy: headers, compress: true, functionAssociations: [{ function: rewrite, eventType: cloudfront.FunctionEventType.VIEWER_REQUEST }], }, additionalBehaviors: { '/media/*': { origin: origins.S3BucketOrigin.withOriginAccessControl(mediaBucket), viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS, cachePolicy: cloudfront.CachePolicy.CACHING_OPTIMIZED, responseHeadersPolicy: headers, compress: true, }, }, errorResponses: [ { httpStatus: 403, responseHttpStatus: 404, responsePagePath: '/404.html', ttl: cdk.Duration.minutes(5) }, { httpStatus: 404, responseHttpStatus: 404, responsePagePath: '/404.html', ttl: cdk.Duration.minutes(5) }, ], })

The 403 mapping matters: a private S3 bucket returns 403 Access Denied for a missing key, and visitors should see your 404 page instead. For more on CloudFront policies, see our posts on managed vs custom response headers policies and origin request policies.

The deploy role for GitHub Actions

The role trusts one branch of one repository, and it can only write to the site bucket and invalidate this distribution:

const provider = new iam.OpenIdConnectProvider(this, 'GithubOidc', { url: 'https://token.actions.githubusercontent.com', clientIds: ['sts.amazonaws.com'], }) const deployRole = new iam.Role(this, 'DeployRole', { maxSessionDuration: cdk.Duration.hours(1), assumedBy: new iam.WebIdentityPrincipal(provider.openIdConnectProviderArn, { StringEquals: { 'token.actions.githubusercontent.com:aud': 'sts.amazonaws.com' }, StringLike: { 'token.actions.githubusercontent.com:sub': `repo:${githubRepo}:ref:refs/heads/${githubBranch}`, }, }), }) siteBucket.grantReadWrite(deployRole) siteBucket.grantDelete(deployRole) deployRole.addToPolicy(new iam.PolicyStatement({ actions: ['cloudfront:CreateInvalidation', 'cloudfront:GetInvalidation'], resources: [`arn:aws:cloudfront::${this.account}:distribution/${distribution.distributionId}`], }))

Keep the :ref:refs/heads/<branch> suffix. GitHub's token subject always includes it, so a condition of just repo:<owner>/<name> never matches.

Clean URLs with a CloudFront Function

S3 doesn't map /about to about.html or about/index.html. A viewer-request CloudFront Function does. This version pairs with Astro's build.format: 'file' and keeps one canonical URL per page:

// - www.example.com -> example.com (301) // - /page/ and /page.html -> /page (301): one URL per page, as the canonical tags say // - /page -> /page.html in the bucket (Astro build.format: 'file') function handler(event) { var request = event.request; var host = request.headers.host ? request.headers.host.value : ''; var uri = request.uri; var qs = Object.keys(request.querystring).length ? '?' + Object.keys(request.querystring).map(function (k) { var v = request.querystring[k]; return encodeURIComponent(k) + (v.value ? '=' + encodeURIComponent(v.value) : ''); }).join('&') : ''; var redirect = function (location) { return { statusCode: 301, statusDescription: 'Moved Permanently', headers: { location: { value: location } } }; }; if (host.indexOf('www.') === 0) return redirect('https://' + host.slice(4) + uri + qs); if (uri.length > 1 && uri.charAt(uri.length - 1) === '/') return redirect(uri.slice(0, -1) + qs); if (uri === '/index.html') return redirect('/' + qs); if (uri.length > 5 && uri.slice(-5) === '.html' && uri !== '/404.html') return redirect(uri.slice(0, -5) + qs); if (uri === '/') request.uri = '/index.html'; else if (uri.lastIndexOf('.') < uri.lastIndexOf('/')) request.uri = uri + '.html'; return request; }

Hosting Payload CMS on Amplify

Payload runs on Amplify Hosting as a Next.js SSR app. The build configuration is short:

version: 1 applications: - appRoot: cms frontend: phases: preBuild: commands: - nvm install 22 && nvm use 22 - npm ci build: commands: - env | grep -E '^(DATABASE_URL|PAYLOAD_SECRET|S3_BUCKET|S3_REGION|CORS_ORIGINS|SMTP_[A-Z]+|GITHUB_[A-Z_]+)=' >> .env.production || true - npx payload migrate - npm run build artifacts: baseDirectory: .next files: - '**/*' cache: paths: - node_modules/**/* - .next/cache/**/*

Three details matter:

  • Environment variables. Variables set in the Amplify console reach the build, but not the Next.js server at runtime. Writing the ones Payload needs into .env.production during the build fixes that.
  • Migrations run in the build, so a schema change deploys together with the code that needs it.
  • Database access. Amplify Hosting can't reach a VPC, so the database must be reachable over the internet. Neon works out of the box with sslmode=require in DATABASE_URL.

Is It Really Free?

In most cases, yes. All limits below were checked on the vendors' pricing pages in November 2026; check them again before you rely on them.

ServiceUsed forFree allowanceAlways free?
CloudFrontServing the whole website1 TB data transfer out, 10M requests, 2M CloudFront Function invocations per monthYes
S3Site and media filesTransfer from S3 to CloudFront is free; storage and requests are billed (cents for a site of this size)No free storage tier for new accounts
Amplify HostingThe Payload CMS1,000 build minutes, 500,000 SSR requests, 100 GB-hours SSR duration, 15 GB data out per monthNo — AWS Free Tier period only
NeonPostgres for Payload100 CU-hours and 1 GB storage per project per month, scales to zero after 5 minutes idleYes (permanent Free plan)
GitHub ActionsBuild and deployFree on public repositories; $12 of included usage per month on private repositories (about 2,000 Linux minutes)Yes

The only service that grows with visitors is CloudFront. Every file counts as a request, so at about 30 files per page view, 10 million requests is roughly 330,000 page views a month. Returning visitors load fewer files because their browsers cache the bundles. Most company websites stay well below that.

If you'd rather have a hard ceiling, CloudFront's flat-rate Free plan costs $0 with no overage charges (1 million requests, 100 GB transfer, 5 GB of S3 storage included).

Everything else grows with editor activity, not traffic. The CMS only sees editors, builds and form posts. Neon is suspended most of the month, and with media in S3 the database stays small.

Where it stops being free:

  • Amplify after your AWS Free Tier ends (12 months on older accounts; up to 6 months on accounts created after July 15, 2025, which get credits instead). Then the CMS pays per use: 0.30 per million SSR requests, 0.20 per GB-hour of SSR duration, $0.01 per build minute. Small at editor-only traffic, but not zero.
  • S3 storage, unless your account still has Free Tier credits. A static site and its images usually amount to cents.
  • Private repositories with frequent publishes and long builds can exceed GitHub's included usage. Without a payment method on file, GitHub blocks further runs instead of charging.
  • Heavy form traffic reaches the CMS, so it counts against Amplify and Neon.
  • Neon limits are hard limits. At 100 CU-hours or 5 GB of egress, the compute is suspended until the next month. Above 1 GB of storage, writes are blocked. The CMS breaks, but the website keeps serving.

That's why free tiers are safe here: if the CMS side runs out of quota, editors wait, and visitors notice nothing.

If you're comparing this with keeping the whole site on Next.js, our Vercel vs AWS Amplify pricing breakdown shows what SSR costs once traffic grows. If you want to stay on Next.js but go static, see deploying a Next.js 16 SSG site on AWS Amplify.

Trade-Offs

  • Publish latency. A small site rebuilds and uploads in a few minutes. Saving isn't publishing, and editors need to know that.
  • Forms are still dynamic. Forms post to a Payload endpoint at runtime, so they fail if the CMS is down. Add the site's origin to Payload's cors and csrf settings, and protect the endpoint with a bot check such as Cloudflare Turnstile.
  • No live preview on the static site. Payload's Live Preview needs a running frontend that renders drafts. Editors preview locally, on a separate preview deployment, or after publishing.
  • Every publish is a full rebuild. Fine for hundreds of pages; for thousands of frequently edited ones, ISR fits better.
  • Cold starts. The first admin request after idle is slower. Visitors aren't affected.

Choose SSR or ISR instead when pages are personalized, when prices or stock change continuously (as in bullion stores priced off live spot prices), or when editors need changes live within seconds.

Conclusion

A CMS is a back-office tool. Rendering pages at publish time, not on every visit, takes it out of the serving path, so the only component that grows with traffic is a CDN with a large free allowance. For a company website, that combination is usually free to host and doesn't need scaling work as traffic grows.

We build and run setups like this, from Payload and Medusa to AWS infrastructure in CDK. If you're weighing static against server-rendered hosting for your CMS, we're happy to talk it through.

Talk to an infrastructure expert

From CDK deployment to custom publishing workflows, we help teams run robust AWS environments. Reach out to u11d for technical guidance.

A person sitting and typing on a laptop keyboard

Frequently Asked Questions

Why does a CMS website usually need a server?

Most modern CMS setups, like Next.js, render content on the fly by querying the database during every request. This couples the rendering process to the CMS, making the server or serverless function part of the mandatory serving path for every visitor.

What is the main benefit of using a static site approach?

By building the site statically at publish time, you decouple the CMS from the visitor. Only the CDN needs to be online, which scales infinitely and often fits within free usage tiers, while the CMS only consumes compute when editors are working.

Can I use Next.js instead of Astro for this architecture?

Yes, you can use a statically exported Next.js site. However, Astro is preferred for static-first projects because it is lighter, ships less client-side JavaScript, and doesn't require workarounds for features like image optimization.

How do editors trigger a site update without using Git?

You can add a custom 'Publish' button to the Payload CMS admin panel. This button triggers a GitHub Actions workflow via the GitHub API, which fetches the latest data, builds the site, and deploys it to S3.

What happens if I run out of the free tier quota on the CMS side?

Because the website is static, visitors will not notice a thing—they continue to see the last published version from the CDN. Only the editing and publishing workflow would be interrupted until your quota resets.

RELATED POSTS
Paweł Swiridow
Paweł Swiridow
Senior Software Engineer

One Dex to rule them all: Argo Workflows SSO through Argo CD

Dec 23, 202619 min read
Article image
Maciej Łopalewski
Maciej Łopalewski
Senior Software Engineer

CloudFront Response Headers: Managed Policies vs. Custom Configurations

Dec 02, 202615 min read
Article image
Robert Szczepanowski
Robert Szczepanowski
Senior Software Engineer

Why Your Next.js App Overflows PostgreSQL Connections (And How to Fix It)

Nov 18, 20269 min read
Article image