This application shows how to integrate Pusher with a Node.js/Express/MongoDB backend and React in the front-end.
- Create an app on Pusher and copy your app's id, key, and secret.`
routes/api.js
const pusher = new Pusher({
appId: "<Pusher App ID>",
key: "<Pusher Api Key>",
secret: "<Pusher Secret>",
cluster: "<Pusher cluster>",
useTLS: true,
});
And
views/index.ejs
var PUSHER_APP_KEY = "<Pusher Api Key>";
- Clone this repository and
cd
into it. - Start the MongoDB server
- Execute
npm install
to download dependencies.
- Go to
http://localhost:3000
and start sending playing with the app using Postman to communicate with the API or the Pusher console to test only the front-end part.
- We have used AJAX requests for Demo
- A free Pusher account
- Node.js version 5 or greater
- A MongoDB database