I'm trying to find how I can make the transition between Express on the server side (for example just to send an email) and using hjs-webpack + ampersand client side routing. I'm still learning how these things are working. I made some SPA which are perfectly working with hjs-webpack + ampersand, but without any data. I also did some apps working with express + angular or standard JS before which were working too.
But now I would like to use the power of hjs-webpack + ampersand client side routing, with a server from where I can get my data or send mails, etc. But I didn't find how to handle the "transition" between my "express app" and my "ampersand-app"(which is referred to in my webpack-config.js)
With React-Router/Redux and express , I would do something like this:
Hy,
I'm trying to find how I can make the transition between Express on the server side (for example just to send an email) and using hjs-webpack + ampersand client side routing. I'm still learning how these things are working. I made some SPA which are perfectly working with hjs-webpack + ampersand, but without any data. I also did some apps working with express + angular or standard JS before which were working too.
But now I would like to use the power of hjs-webpack + ampersand client side routing, with a server from where I can get my data or send mails, etc. But I didn't find how to handle the "transition" between my "express app" and my "ampersand-app"(which is referred to in my webpack-config.js)
With React-Router/Redux and express , I would do something like this:
app.use((req, res) => { match({ routes: routes(), location: req.url }, (error, redirectLocation, renderProps) => { if (error) { res.status(500).send(error.message) } else if (redirectLocation) { res.redirect(302, redirectLocation.pathname + redirectLocation.search) } else if (renderProps) { const body = ReactDOMServer.renderToString( React.createElement(Provider, {store}, React.createElement(RouterContext, renderProps) ) ) res.status(200).send(template({body})) } else { res.status(404).send('Not found') } }) })
But I don't know how to make things work with ampersand-router, react and hjs-webpack
Could you or someone give me some advices ? Or places to look at, still didn't find infos on google about it.
Thanks in advance.