AWS Amplify preset doesn't support mixed render modes
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 11.2k
- Forks
- 899
- Avg merge
- 2d 24m
- Merged PRs (30d)
- 40
Description
Describe the feature
The current preset does not support mixed render modes, e.g. Nuxt can deliver a SSR App with some prerendered pages. Amplify has issues to detect if a requested route is SSR or SSG, by default its calling SSR. If the route is SSG, this will result in a 500 error, because there is no "fallthrough". The preset itself support SSG, but only if the complete app i SSG, not mixed.
I think there are multiple possible solutions:
- Fallthrough: Serve statically all assets, if asset does not exists in bucket, the Server is requested
- Cloudfront Function / Lambda@Edge: A function with least possible overhead acts in front of the app, reads route config and pass request to right location
- SSR with long revalidation and warmup: Despite prerendering is configured, actually all routes are rendered with SWR and after build a warmup request triggers cache to have near SSG performance
Also look inside other presets for inspiration (Netlify / Vercel).
Just some ideation, not tested
export default defineNitroPreset({
name: 'amplify-static-fallback',
extends: 'aws-amplify',
hooks: {
// After Nitro has compiled server + static assets
'nitro:compiled': async (nitro) => {
const outDir = nitro.options.output.dir
const manifestDir = join(outDir, '.amplify-hosting')
const staticDir = nitro.options.output.publicDir
// Ensure the folder exists
await fs.mkdir(manifestDir, { recursive: true })
// Deploy manifest: single static-first + SSR fallback
const deployManifest = {
version: 1,
appRoot: outDir,
staticAssets: {
root: staticDir
},
routes: [
{
path: '/*',
target: { kind: 'Static' },
fallback: { kind: 'Compute', src: 'default' }
}
]
}
const manifestPath = join(manifestDir, 'deploy-manifest.json')
await fs.writeFile(manifestPath, JSON.stringify(deployManifest, null, 2))
console.log('[Amplify Preset] Written static-first + fallback deploy-manifest.json')
}
}
})
Additional information
- Would you be willing to help implement this feature?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the AWS Amplify preset and its nitro:compiled entry point, then compare the Netlify and Vercel presets for handling mixed SSR and SSG routes. Define and validate one approach that serves prerendered routes without a 500 while retaining SSR fallback; the issue does not name a specific test or file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, nuxt, typescript
- Domain
- build-system, cloud
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100