diff --git a/examples/chat-room-history/javascript/.env.example b/examples/chat-room-history/javascript/.env.example new file mode 100644 index 0000000000..acd79e16f2 --- /dev/null +++ b/examples/chat-room-history/javascript/.env.example @@ -0,0 +1 @@ +VITE_PUBLIC_ABLY_KEY= \ No newline at end of file diff --git a/examples/chat-room-history/javascript/.gitignore b/examples/chat-room-history/javascript/.gitignore new file mode 100644 index 0000000000..fd3dbb571a --- /dev/null +++ b/examples/chat-room-history/javascript/.gitignore @@ -0,0 +1,36 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js +.yarn/install-state.gz + +# testing +/coverage + +# next.js +/.next/ +/out/ + +# production +/build + +# misc +.DS_Store +*.pem + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# local env files +.env*.local + +# vercel +.vercel + +# typescript +*.tsbuildinfo +next-env.d.ts diff --git a/examples/chat-room-history/javascript/README.md b/examples/chat-room-history/javascript/README.md new file mode 100644 index 0000000000..d6923ae9a3 --- /dev/null +++ b/examples/chat-room-history/javascript/README.md @@ -0,0 +1,39 @@ +# Message history for chat applications + +This folder contains the code for message history (Typescript) - a demo of how you can leverage [Ably Chat](https://ably.com/docs/products/chat?lang=javascript) to retrieve the historical messages when joining a room. + +## Getting started + +1. Clone the [Ably docs](https://github.com/ably/docs) repository where this example can be found: + +```sh +git clone git@github.com:ably/docs.git +``` + +2. Change directory: + +```sh +cd /examples/chat-room-history/javascript/ +``` + +3. Rename the environment file: + +```sh +mv .env.example .env.local +``` + +4. In `.env.local` update the value of `VITE_PUBLIC_ABLY_KEY` to be your Ably API key. + +5. Install dependencies: + +```sh +yarn install +``` + +6. Run the server: + +```sh +yarn run dev +``` + +7. Try it out by opening two tabs, one to [http://localhost:5173?loadChat=true](http://localhost:5173?loadChat=true) and one to [http://localhost:5173/](http://localhost:5173/) with your browser to see the result. diff --git a/examples/chat-room-history/javascript/index.html b/examples/chat-room-history/javascript/index.html new file mode 100644 index 0000000000..a7e81f715e --- /dev/null +++ b/examples/chat-room-history/javascript/index.html @@ -0,0 +1,71 @@ + + +
+ + + + +