This project demonstrates how to add Twitter's realtime likes functionality to your Node app with Pusher. Here's a walkthrough.
The app's homepage displays a list of posts. Open the app in several different browser windows or tabs simultaneously. You'll see that liking a post in one window reflects across all windows wthout needing a page refresh.
- Node.js (v6.0.0 or higher)
- MongoDB (v3.4.0 or higher)
- A Pusher account and a Pusher app credentials
Clone the project:
git clone https://github.com/shalvah/poster
Put your Pusher app credentials in a .env
file in the project root:
PUSHER_APP_ID=your-app-id
PUSHER_APP_KEY=your-app-key
PUSHER_APP_SECRET=your-app-secret
PUSHER_APP_CLUSTER=your-app-cluster
Look for these lines of JavaScript in views/index.hbs
:
var pusher = new Pusher('your-app-id', {
cluster: 'your-app-cluster'
});
Insert your Pusher app ID and cluster in the appropriate places.
Start your MongoDB server by running mongod
.
Then:
node bin/seed.js
npm start
- Pusher - APIs for building realtime features
- Twitter!