AWS released SSR support on May 18th, 2021: https://aws.amazon.com/about-aws/whats-new/2021/05/aws-amplify-hosting-announces-server-side-rendering-support-for-next-js-web-apps/
I've been able to deploy a Next.js app without any issues, however, when attempting to deploy a custom React SSR app, I'm not sure how to do it, and there doesn't appear to be any documentation / blogs about it... is it even possible?
For example, here is my ampify.yml
file:
version: 1
frontend:
phases:
preBuild:
commands:
- yarn install
build:
commands:
- yarn run build
artifacts:
baseDirectory: dist
files:
- '**/*'
cache:
paths:
- node_modules/**/*
Here is the relevant scripts from my package.json
file:
"scripts": {
"prod::ssr": "cross-env NODE_ENV=production MODE=ssr webpack",
"prod::client": "cross-env NODE_ENV=production MODE=client webpack",
"build": "npm run prod::ssr && npm run prod::client",
"start": "node dist/ssr/index.js"
},
This works fine locally, but not on AWS Ampify.
My understanding is AWS Ampify uses the start
command to run the app... is this true?
It seems that currently Amplify only supports SSR for Next.JS https://docs.aws.amazon.com/amplify/latest/userguide/server-side-rendering-amplify.html#ssr-Amplify-support
The solution on AWS would probably be to use Lambda https://aws.amazon.com/blogs/compute/building-server-side-rendering-for-react-in-aws-lambda/