Deploying Create React App on Fly

Is there a guide for deploying react clients on fly? Is this something that should even be done?

I have tried using the static builtin with no luck. Was trying to keep “everything” at fly.io but if Netlify is still a better option for this, we can host the one react client we have there and the nextjs on fly being that its SSR.

Thanks in advance

If this is a “full stack app” with a React client, Fly.io is a good place to host the react bits. Is it part of the Next app repo?

Netlify is a better place for a standalone client app.

1 Like

This particular deployment is a standalone CRA client. Sounds like for now we should just deploy this on Netlify.

As for the other client, we plan to have this on fly being that its a NextJS app running next-boost (next-boost - npm) for caching.

Anything to look out for here? This is eventually where we want to really take advantage of the read PG replicas as this is the “checkout page” that will be running in a lot of regions to reduce latency and increase page load performance.

Thanks!

The [static] block is built for that kind of app. It’s sometimes harder than it should be to bundle static assets AND an app server together in a JS app. But all you need is a Dockerfile that runs the app server and the assets in the same image: First look: static asset caching

1 Like

If you have the the app code copied into /app on the container, and run yarn build, then statics configuration will look like

[[statics]]
  guest_path = "/app/build"
  url_prefix = "/"

It does make sense to run the serve command as well, because running a purely static file set on fly will not automatically serve index.html at the root path /, etc.

Ah, this makes sense, to be completely honest, I have never needed to use the serve command from the cli, I think this might be the missing part. I have the app successfully deploying to Netlify at the moment, but will absolutely play with this again in the future.

I also am not a caching expert by any means, so the “magic” that Netlify provides in this regard is also appealing to us.

Yeah Netlify is really good for static client apps. We’re really good for full stack + some static client assets. It makes total sense to use them for what you’re doing.

1 Like

Yeah. If you’re doing a completely pure static site, Netlify or Cloudflare Pages may be a better idea. If you have any API calls, or if you’re using Next.js + SSR or anything else that has a backend, or just adding fronting on an API, Fly works much better.

1 Like