├── example.env ├── public └── favicon.ico ├── .gitignore ├── remix.env.d.ts ├── vercel.json ├── app ├── entry.client.tsx ├── components │ ├── Header.tsx │ ├── Room.tsx │ ├── Live.tsx │ ├── Avatar.tsx │ ├── Footer.tsx │ ├── Join.tsx │ └── Conference.tsx ├── entry.server.tsx ├── root.tsx ├── routes │ └── index.tsx ├── meeting.tsx └── styles │ └── global.css ├── api └── index.js ├── remix.config.js ├── tsconfig.json ├── README.md ├── package.json └── LICENSE /example.env: -------------------------------------------------------------------------------- 1 | # Get it from https://dashboard.100ms.live/developer 2 | HMS_TOKEN_ENDPOINT= -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Deep-Codes/remix-video-chat/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | 3 | .cache 4 | .vercel 5 | .output 6 | 7 | public/build 8 | api/_build 9 | .env -------------------------------------------------------------------------------- /remix.env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /vercel.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "env": { 4 | "ENABLE_FILE_SYSTEM_API": "1" 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /app/entry.client.tsx: -------------------------------------------------------------------------------- 1 | import { hydrate } from 'react-dom'; 2 | import { RemixBrowser } from "@remix-run/react"; 3 | 4 | hydrate(, document); 5 | -------------------------------------------------------------------------------- /api/index.js: -------------------------------------------------------------------------------- 1 | const { createRequestHandler } = require("@remix-run/vercel"); 2 | 3 | module.exports = createRequestHandler({ 4 | build: require("./_build") 5 | }); 6 | -------------------------------------------------------------------------------- /app/components/Header.tsx: -------------------------------------------------------------------------------- 1 | const Header = () => { 2 | return ( 3 |
4 |

REMIX VIDEO CHAT

5 |
6 | ); 7 | }; 8 | 9 | export default Header; 10 | -------------------------------------------------------------------------------- /app/components/Room.tsx: -------------------------------------------------------------------------------- 1 | import Conference from './Conference'; 2 | import Footer from './Footer'; 3 | import Header from './Header'; 4 | 5 | const Room = () => { 6 | return ( 7 |
8 |
9 | 10 |
11 |
12 | ); 13 | }; 14 | 15 | export default Room; 16 | -------------------------------------------------------------------------------- /remix.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @type {import('@remix-run/dev/config').AppConfig} 3 | */ 4 | module.exports = { 5 | appDirectory: 'app', 6 | assetsBuildDirectory: 'public/build', 7 | publicPath: '/build/', 8 | serverBuildDirectory: 'api/_build', 9 | ignoredRouteFiles: ['.*'], 10 | routes(defineRoutes) { 11 | return defineRoutes((route) => { 12 | route('/meeting/*', 'meeting.tsx'); 13 | }); 14 | }, 15 | }; 16 | -------------------------------------------------------------------------------- /app/components/Live.tsx: -------------------------------------------------------------------------------- 1 | import { selectIsConnectedToRoom, useHMSStore } from '@100mslive/react-sdk'; 2 | import React from 'react'; 3 | import Join from '~/components/Join'; 4 | import Room from '~/components/Room'; 5 | 6 | const Live: React.FC<{ token: string }> = ({ token }) => { 7 | const isConnected = useHMSStore(selectIsConnectedToRoom); 8 | return
{isConnected ? : }
; 9 | }; 10 | 11 | export default Live; 12 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx"], 3 | "compilerOptions": { 4 | "lib": ["DOM", "DOM.Iterable", "ES2019"], 5 | "isolatedModules": true, 6 | "esModuleInterop": true, 7 | "jsx": "react-jsx", 8 | "moduleResolution": "node", 9 | "resolveJsonModule": true, 10 | "target": "ES2019", 11 | "strict": true, 12 | "baseUrl": ".", 13 | "paths": { 14 | "~/*": ["./app/*"] 15 | }, 16 | "noEmit": true, 17 | "allowJs": true, 18 | "forceConsistentCasingInFileNames": true 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Remix Video Chat 2 | 3 | Video chat app with Remix and 100ms React SDK in less than 100 lines of code. 4 | 5 | Try out the [Public demo](https://remix-video-chat.vercel.app/meeting/6210d32e71bd215ae0423a3c/host) 6 | 7 | [Read this Detailed blog](http://dpnkr.in/blog/remix-video-chat-app) for understanding the code and setup. 8 | 9 | [![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2FDeep-Codes%2Fremix-video-chat&env=HMS_TOKEN_ENDPOINT&envDescription=Token%20endpoint%20can%20be%20found%20in%20developer%20section%20of%20100ms%20Dashboard.&envLink=https%3A%2F%2Fdashboard.100ms.live%2Fdeveloper) 10 | -------------------------------------------------------------------------------- /app/entry.server.tsx: -------------------------------------------------------------------------------- 1 | import { renderToString } from "react-dom/server"; 2 | import { RemixServer } from "@remix-run/react"; 3 | import type { EntryContext } from "@remix-run/node"; 4 | 5 | export default function handleRequest( 6 | request: Request, 7 | responseStatusCode: number, 8 | responseHeaders: Headers, 9 | remixContext: EntryContext 10 | ) { 11 | const markup = renderToString( 12 | 13 | ); 14 | 15 | responseHeaders.set("Content-Type", "text/html"); 16 | 17 | return new Response("" + markup, { 18 | status: responseStatusCode, 19 | headers: responseHeaders 20 | }); 21 | } 22 | -------------------------------------------------------------------------------- /app/components/Avatar.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const Avatar: React.FC<{ name: string }> = ({ name }) => { 4 | const initials = getInitials(name); 5 | return {initials}; 6 | }; 7 | 8 | // @see https://stackoverflow.com/questions/33076177/getting-name-initials-using-js 9 | const getInitials = (name: string) => { 10 | const allNames = name.trim().split(' '); 11 | const initials = allNames.reduce((acc, curr, index) => { 12 | if (index === 0 || index === allNames.length - 1) { 13 | acc = `${acc}${curr.charAt(0).toUpperCase()}`; 14 | } 15 | return acc; 16 | }, ''); 17 | return initials; 18 | }; 19 | 20 | export default Avatar; 21 | -------------------------------------------------------------------------------- /app/components/Footer.tsx: -------------------------------------------------------------------------------- 1 | import { useAVToggle, useHMSActions } from '@100mslive/react-sdk'; 2 | import { 3 | MicOffIcon, 4 | MicOnIcon, 5 | VideoOffIcon, 6 | VideoOnIcon, 7 | HangUpIcon, 8 | } from '@100mslive/react-icons'; 9 | 10 | function Footer() { 11 | const { isLocalAudioEnabled, isLocalVideoEnabled, toggleAudio, toggleVideo } = 12 | useAVToggle(); 13 | const actions = useHMSActions(); 14 | return ( 15 |
16 | 19 | 22 | 25 |
26 | ); 27 | } 28 | 29 | export default Footer; 30 | -------------------------------------------------------------------------------- /app/components/Join.tsx: -------------------------------------------------------------------------------- 1 | import { useHMSActions } from '@100mslive/react-sdk'; 2 | import React, { useState } from 'react'; 3 | 4 | const Join: React.FC<{ token: string }> = ({ token }) => { 5 | const actions = useHMSActions(); 6 | const [name, setName] = useState(''); 7 | const joinRoom = () => { 8 | actions.join({ 9 | authToken: token, 10 | userName: name, 11 | }); 12 | }; 13 | return ( 14 |
{ 16 | e.preventDefault(); 17 | joinRoom(); 18 | }} 19 | > 20 |

Join Room

21 | setName(e.target.value)} 24 | required 25 | type='text' 26 | placeholder='Enter Name' 27 | maxLength={20} 28 | minLength={2} 29 | /> 30 | 31 |
32 | ); 33 | }; 34 | 35 | export default Join; 36 | -------------------------------------------------------------------------------- /app/root.tsx: -------------------------------------------------------------------------------- 1 | import { 2 | Links, 3 | LiveReload, 4 | Meta, 5 | Outlet, 6 | Scripts, 7 | ScrollRestoration, 8 | } from "@remix-run/react"; 9 | import type { MetaFunction } from "@remix-run/node"; 10 | import { HMSRoomProvider } from '@100mslive/react-sdk'; 11 | 12 | export const meta: MetaFunction = () => { 13 | return { title: 'Remix Video Chat' }; 14 | }; 15 | 16 | export default function App() { 17 | return ( 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | {process.env.NODE_ENV === 'development' && } 31 | 32 | 33 | 34 | ); 35 | } 36 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "remix-video-chat", 3 | "description": "Video chat app with Remix and 100ms react sdk in less than 100 lines of code.", 4 | "license": "MIT", 5 | "repository": { 6 | "url": "https://github.com/Deep-Codes/remix-video-chat" 7 | }, 8 | "scripts": { 9 | "build": "remix build", 10 | "dev": "node -r dotenv/config node_modules/.bin/remix dev --port 3000", 11 | "postinstall": "remix setup node" 12 | }, 13 | "dependencies": { 14 | "@100mslive/react-icons": "^0.0.7", 15 | "@100mslive/react-sdk": "^0.3.0", 16 | "@remix-run/react": "^1.6.8", 17 | "@remix-run/serve": "^1.6.8", 18 | "@remix-run/vercel": "^1.6.8", 19 | "react": "^17.0.2", 20 | "react-dom": "^17.0.2", 21 | "remix": "^1.1.3" 22 | }, 23 | "devDependencies": { 24 | "@remix-run/dev": "^1.6.8", 25 | "@types/react": "^17.0.24", 26 | "@types/react-dom": "^17.0.9", 27 | "dotenv": "^16.0.0", 28 | "typescript": "^4.1.2" 29 | }, 30 | "engines": { 31 | "node": ">=14" 32 | }, 33 | "sideEffects": false 34 | } 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022-onwards Deepankar Bhade 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /app/components/Conference.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { 3 | HMSPeer, 4 | selectIsPeerAudioEnabled, 5 | selectIsPeerVideoEnabled, 6 | selectPeers, 7 | useHMSStore, 8 | useVideo, 9 | } from '@100mslive/react-sdk'; 10 | import Avatar from './Avatar'; 11 | import { MicOffIcon, MicOnIcon } from '@100mslive/react-icons'; 12 | 13 | const Conference = () => { 14 | const peers = useHMSStore(selectPeers); 15 | return ( 16 |
17 | {peers.map((peer) => ( 18 | 19 | ))} 20 |
21 | ); 22 | }; 23 | 24 | const Peer: React.FC<{ peer: HMSPeer }> = ({ peer }) => { 25 | const isAudioOn = useHMSStore(selectIsPeerAudioEnabled(peer.id)); 26 | const isVideoOn = useHMSStore(selectIsPeerVideoEnabled(peer.id)); 27 | return ( 28 |
29 | {!isVideoOn ? : null} 30 | {peer.name} 31 |
36 | ); 37 | }; 38 | 39 | const Video = ({ videoTrack, mirror }: any) => { 40 | const { videoRef } = useVideo({ 41 | trackId: videoTrack, 42 | }); 43 | return ( 44 |