In this tutorial you'll add real-time one-to-one chat to a React + TypeScript app built with Webpack, using QuickBlox. Two authenticated users exchange private messages that arrive in the browser the moment they are sent, with persistent message history across reloads. The SDK is installed as a regular npm dependency and imported the standard React way.
The full published tutorial walks through every step with explanations and screenshots: How to Build In-App Chat in a React Web Application. This folder is the finished project you can clone and run.
This variant is for teams already on Webpack — for example, when adding chat to an existing Create React App or a custom Webpack 5 build. If you're starting a new project, the React + Vite variant is the recommended default.
- React 19
- TypeScript 5.7
- Webpack 5 with
ts-loader,style-loader,css-loader,html-webpack-plugin(port3008) - QuickBlox JavaScript SDK 2.23.0 — installed via
npm install quickblox
-
Open
src/config.ts— the only file you edit — and fill in your values:- App Credentials from the QuickBlox Dashboard (Overview tab → Application ID, Authorization Key, Authorization Secret, Account Key).
- Two test users in the
usersobject: for each ofAandB, paste thelogin,password, andopponentId— the other user's numeric ID from Dashboard → Users →IDcolumn.
-
Install dependencies and start the Webpack dev server:
npm install npm start
-
Open two browser tabs to see real-time delivery in both directions:
- Tab 1:
http://localhost:3008/?user=A— signs in as User A, opponent is User B. - Tab 2:
http://localhost:3008/?user=B— signs in as User B, opponent is User A.
Each tab pre-fills the login form with the matching profile from
config.ts. Press Sign in in each tab and start sending messages. - Tab 1:
react-webpack/
├── public/index.html The HTML shell — html-webpack-plugin injects the bundle
├── package.json Includes 'overrides' for the SDK's platform shims
├── tsconfig.json
├── webpack.config.js resolve.alias + resolve.fallback for the SDK
└── src/
├── index.tsx React entry — createRoot(...).render(<App />)
├── App.tsx Shell: state.user ? <ChatScreen /> : <LoginScreen />
├── config.ts Your credentials — the only file you edit
├── types/quickblox.ts Narrow app-level types for SDK shapes
├── services/
│ ├── auth.ts QB.init / QB.createSession / QB.chat.connect
│ └── chat.ts QB.chat.dialog.create / message.list / send
├── context/ Context + useReducer-backed chat state
├── hooks/ useAuth / useDialog / useMessages / useChatListeners
├── components/ LoginScreen / ChatScreen / Conversation / MessageList / MessageInput
└── styles/App.css
The contents of src/ are byte-for-byte identical to the React + Vite variant. The only differences are the entry filename (index.tsx here vs main.tsx for Vite) and the surrounding build configuration.
The QuickBlox SDK declares two platform-specific shim packages — for NativeScript and for Node — that it only requires when running on those platforms. In a browser bundle those require calls sit on dead branches, so they never execute. But Webpack 5 still tries to resolve them at build time, and it dropped automatic Node-built-in polyfills as well.
Two fixes are applied:
-
package.jsonoverridesreplaces the two unused shim packages with the no-opnoop2package, so Webpack resolves them to an empty module:"overrides": { "quickblox": "$quickblox", "nativescript-xmpp-client": "npm:noop2@^2.0.0", "node-xmpp-client": "npm:noop2@^2.0.0" }
-
webpack.config.jsmarks the same two packages as ignored inresolve.aliasand tells Webpack 5 to omit thefsandosNode built-ins:resolve: { alias: { 'nativescript-xmpp-client': false, 'node-xmpp-client': false, }, fallback: { fs: false, os: false }, }
This project signs the user in directly from the browser to keep the example self-contained. In production, do not ship the Authorization Secret in browser code — anyone who reads it can authenticate as any user in your application. Move authentication to your backend and pass a short-lived session token to the client instead.
The same React source code is also available with Vite as the build tool — recommended for new projects: React + Vite.
- Published tutorial → How to Build In-App Chat in a React Web Application
- React tutorials hub → ../README.md
- JavaScript SDK reference → docs.quickblox.com/docs/js-quick-start