/react-native-phoenix-chat-example

An example React Native chat application with Phoenix

Primary LanguageJavaScript

An example React Native chat application with Phoenix.

Requirements

Installation

Client

  • Build React Native client
cd client
npm install
# ios
react-native run-ios
# android
react-native run-android

Running on real device

If you running the application on an actual device, replace api server endpoint with your host ip address.

Chat.js

const URL = '//localhost/socket'

Root.js

const HOST = 'localhost'

Server

  • Running phoenix server with docker
cd server
make up
  • see logs
$ docker logs -f chat_app
...
[info] Running Server.Endpoint with Cowboy using http://localhost:4000

# Confirm Running
$ curl localhost/messages
{"messages":[]}%

Running server manually

  • Run Redis and Postgres on localhost
  • Configure postgres username & password

config/dev.exs

username: "postgres",
password: "postgres",
database: "server_dev",
hostname: "localhost",

configure redis host

config :redix,
  host: "localhost",
  • Run Phoenix server
mix deps.get
mix phoenix.server