how to build react js server side jpx and use it on client side with a php server?

378 Views Asked by At

I am quite new with React js and I'm pretty sure there are concepts that I am missing and fail to find the right answers to my questions.

So I have a simple php project running on nginx, I am wondering if I can somehow avoid using a webpack server or react js server to do server side rendering and instead compile the jsx code with some sort of a watcher to then be used on client side.

The reason for this is because I realised if I only add

<script src="https://unpkg.com/react@17/umd/react.production.min.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@17/umd/react-dom.production.min.js" crossorigin></script>

in the head and use the babel watcher with

npx babel --watch <indir> --out-dir <outdir> --presets react-app/prod

then I am unable to use open source libraries, such as react-easy-crop since they are built for server side rendering.

long story shorter, is there a way for me to compile what server side rendering would do, and use it for client side rendering?

0

There are 0 best solutions below