React Native real-time Tic-tac-toe app
A tic-tac-toe app created with React Native and Pusher. Tutorial is available at the Pusher Tutorial Hub: Creating a real-time game with React Native.
Note: the React Native code in this repo may be a little bit outdated and won't run immediately after you've followed the setup instructions. Be sure to refactor the code to use the more recent React Native syntax if it doesn't run for you.
Prerequisites
- React Native development environment
- Pusher account and pusher app
Getting Started
- Create a new React Native project:
react-native init RNPusherTicTacToe
- Clone the repo in another directory:
git clone https://github.com/anchetaWern/RN-Pusher-TicTacToe.git
- Navigate inside the
appdirectory of the cloned repo:
cd RN-Pusher-TicTacToe/app
-
Copy the
componentsfolder andpackage.jsonfile and paste it on your React Native project. -
Copy the contents of
index.android.jsfrom the cloned repo: https://github.com/anchetaWern/RN-Pusher-TicTacToe/blob/master/app/index.android.js and paste it in theindex.jsfile of your React Native project. -
Navigate inside the
serverdirectory of the cloned repo and update the.envfile with your Pusher app details:
cd RN-Pusher-TicTacToe/server
touch .env
- Still inside the
serverdirectory, install the server dependencies:
npm install
-
Use now.sh to deploy the server or use Ngrok to simply expose it to the internet. Take note of the URL as this will serve as the base URL for the auth endpoint to be used by Pusher. The auth endpoint is
/pusher/auth. -
Navigate inside the root directory of your React Native project and install the dependencies:
npm install
-
Still in the root directory of your React Native project, open the
components/Main.jsfile and update the placeholder values with your Pusher app details and auth endpoint (example: https://myapp.ngrok.com/pusher/auth) -
Run the app:
react-native run-android
Built With
Donation
If this project helped you reduce time to develop, please consider buying me a cup of coffee :)
