Closed rajatdua closed 2 years ago
As it's hash-router I'm not sure if it will work with pre-rendering - SSR.
"build": "APP_ENV=production preact build",
P.S: The build script which I used for npm run build
Yes, hash routers only work in the browser. Preact-CLI prerenders your app in Node, therefore they're not really compatible.
You can get around this by dropping out of prerendering or using window checks (see https://github.com/preactjs/preact-cli#pre-rendering). However, without the router being available, there's likely little value in prerendering.
I was testing Preact and wanted to check hash history routing. I followed the following JS Fiddle from developit about how to implement hash-routing.
The problem comes down when I run
npm run build
passing history prop in Router - createHashHistory() causes build error with the following error message -Code for reference -
App.js
Nav.js
I used the same version for the libraries mentioned in the fiddle and also tried with the latest versions too.
JS Fiddle
New Versions
Preact-CLI versions, which I tested on
"preact-cli": "^3.0.0", "preact-cli": "^3.0.1",