mfng icon indicating copy to clipboard operation
mfng copied to clipboard

[Doubt] Can i deploy react app with static build and serverless react components?

Open useEffects opened this issue 1 year ago • 6 comments

We are exactly looking for this approach

using an AWS Lambda Function, with AWS CloudFront as CDN

I am skimming through the aws-app code and I couldnt find where you are building the react app as a static export, you are only deploying the entire application to a lambda, which we are not looking for. We are looking for deploying the react app as a bundle in CDN, power the react server components through lambda functions.

useEffects avatar Sep 02 '24 20:09 useEffects

I really think what we are looking for is possible through this repo :)

useEffects avatar Sep 02 '24 20:09 useEffects

MFNG does not offer a static export of pages as it does not have a concept of file-based routes. The static client assets as well as the server-side rendered responses can be cached in a CDN though, which the AWS example app has configured in https://github.com/unstubbable/mfng/blob/main/apps/aws-app/cdk/stack.ts.

unstubbable avatar Sep 03 '24 06:09 unstubbable

We are looking for an SPA static export with RSC, the RSC not only be bundled at build time, but the RSC components should be hydrated through serverless functions.

useEffects avatar Sep 03 '24 07:09 useEffects

if you couldnt figure out what I am trying to look for, please let me know :)

useEffects avatar Sep 03 '24 07:09 useEffects

Statically built RSC components don't need serverless functions to be hydrated. You only need a CDN and a browser to accomplish that. But again, MFNG does not offer a static build of RSC components. Instead, it needs a request handler (e.g. a serverless function) to render them at request time (in case of a CDN cache MISS). If you're looking to create fully or partially static RSC output at build time, I recommend using Next.js.

unstubbable avatar Sep 03 '24 07:09 unstubbable

we dont want static build of RSC components either, I will play with the repo for now and let you know if this can fulfill our requirements. Next.js is out of our scope because we only want static export of a single react component and deploy it in CDN which later can be used in html pages.

useEffects avatar Sep 03 '24 07:09 useEffects