You can do this with Server-side rendering (SSR). I don't know what kind of tools/build chain you are using with react, but Vite supports SSR for example, Next.js does as well. The question is rather generic, but this answer should put you in the right direction.