itsa-react-server
v18.0.3
Published
itsa-react-server Hapi plugin
Maintainers
Readme
itsa-react-server
Build high-performent and easy manageable SPAs based on React.js MVC server for serverside rendered react apps.
You can use the itsa-cli to setup new web-applications. A full description, visit http://itsaserver.io.
Upgrading to 18.0.0
Version 18 moves from hapi 16 to hapi 21 and from React 15 to React 16. It is a breaking release: every app built on itsa-react-server needs code changes. The full guide with before/after examples is MIGRATION-18.md; this is the checklist.
What your app needs
- Node.js 14 or later (tested on Node 24).
- Dependencies: remove
hapi; install@hapi/hapi@^21,itsa-react-server@^18,react@^16.14.0andreact-dom@^16.14.0. Replaceboom/hoek/inert/visionwith their@hapi/*packages if your app uses them directly. src/manifest.json: replacereact/dist/...andreact-dom/dist/...paths inexternal-moduleswith the React 16umd/files (table in the guide).server.js: create the server withHapi.server(Object.assign(reactServer.getServerOptions(manifest), {...your options})), thenawait server.register({plugin: reactServer, options: manifest})andawait server.start(). Noserver.connection(), no callbacks.- Routes (
src/routes.js): every handler returns —handler: (request, h) => h.reactview('index'). A handler withoutreturnanswers 500. replybecomesheverywhere: route handlers, actions (src/actions), models (src/models,src/model-general.js,src/initial-globalstate.js) and the authenticationvalidateFunc.reply.reactview/action/assets/login/logout/generateProps/setBodyDataAttrbecome the same methods onh;reply.requestbecomesh.request.- Actions return their response:
reply(stream).header(...)becomesreturn h.response(stream).header(...); a returned value is sent as before. - React 15 → 16 component changes:
React.PropTypesandReact.createClassare gone. - Check the behaviour changes: cookies are sent with
SameSite=Lax;request.urlis a WHATWGURL(usepathname/search); multipart uploads parsed by hapi needpayload: {multipart: true}; an empty response answers 204 instead of 200;.jsassets are served astext/javascript; a failing plugin start now makesserver.register()reject.
Security fix — upgrade soon. Up to 17.x, an asset URL with an encoded ../
(for example /assets/..%2F..%2F..%2F..%2F.cookierc) can read any file of the app, including the
cookie passwords in .cookierc. 18.0.0 confines every asset route to its own directory.
Installation
Step 1: install itsa-cli globally:
npm install -g itsa-cliCreating applications
Once you have all these packages, you can create a new web-application like this:
Create a new application:
itsa create appnameappname will become a new folder with all appropriate files.
Check the new application
Goto the created folder and run:
npm run startAs soon as the message Server running development at port: 3001 appears, you can open a browser and visit http://localhost:3001. The Hello World! app should come up.
See http://itsaserver.io for the complete documentation and usage.
Using .scss files (since 17.0.0)
Sass is compiled by Dart Sass (sass) instead of node-sass, which does not support Node.js 24. Every app that uses .scss adds options: { implementation: require('sass') } to its sass-loader rule:
{
test: /\.scss$/,
use: [
// ...your other loaders
{
loader: 'sass-loader',
options: { implementation: require('sass') }
}
]
}You can start right away building your application. Any help can be found at http://itsaserver.io.
If you want to express your appreciation
Feel free to donate to one of these addresses; my thanks will be great :)
- Ether: 0xE096EBC2D19eaE7dA8745AA5D71d4830Ef3DF963
- Bitcoin: 37GgB6MrvuxyqkQnGjwxcn7vkcdont1Vmg
