preact-ssr icon indicating copy to clipboard operation
preact-ssr copied to clipboard

preact-router doesn't properly render on server

Open markusenglund opened this issue 7 years ago • 1 comments

Hey, I just wanted to clue you in on the fact that preact-router doesn't really work when server rendering. I've been looking around for how to do it, and it doesn't seem like it's supported. You'll notice when you open your app at the "/about" route, that the server renders the "/" route, and then javascript on the client goes ahead and changes it. So the about page is never rendered on the server, which kind of defeats the purpose of ssr.

I made the same mistake since it's hard to notice that anything is out of order.

I think the best way to do ssr with preact is to just stick with good old react-router.

markusenglund avatar May 14 '18 16:05 markusenglund

I was wrong, it is supported in preact-router. You just have to pass the url to the router like described here: https://github.com/developit/preact-router/issues/207

markusenglund avatar May 14 '18 22:05 markusenglund