2022-10-24 17:03:12 +02:00
|
|
|
import type { NextPage } from 'next';
|
|
|
|
import { useRouter } from 'next/router';
|
|
|
|
import styles from '../styles/Home.module.css';
|
|
|
|
|
|
|
|
const Home: NextPage = () => {
|
|
|
|
const router = useRouter();
|
|
|
|
const startMeeting = () => {
|
|
|
|
router.push(`/rooms/${generateRoomId()}`);
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
2023-01-19 19:56:00 +01:00
|
|
|
<>
|
|
|
|
<main className={styles.main}>
|
|
|
|
<div className="header">
|
|
|
|
<img src="/images/livekit-meet-home.svg" alt="LiveKit Meet" width="480" height="60" />
|
|
|
|
<h2>
|
|
|
|
Open source video conferencing app built on LiveKit Components, LiveKit Cloud,
|
|
|
|
and Next.js.
|
|
|
|
</h2>
|
|
|
|
</div>
|
|
|
|
<button
|
|
|
|
style={{ fontSize: '1.25rem', paddingInline: '1.25rem' }}
|
|
|
|
className="lk-button"
|
2022-10-24 17:03:12 +02:00
|
|
|
onClick={startMeeting}
|
|
|
|
>
|
|
|
|
Start Meeting
|
2023-01-19 19:56:00 +01:00
|
|
|
</button>
|
2022-10-24 17:03:12 +02:00
|
|
|
</main>
|
2023-01-19 19:56:00 +01:00
|
|
|
<footer>
|
|
|
|
Hosted on{' '}
|
|
|
|
<a href="https://livekit.io/cloud?ref=meet" target="_blank" rel="noreferrer">
|
|
|
|
LiveKit Cloud
|
|
|
|
</a>
|
|
|
|
. Source code on{' '}
|
|
|
|
<a
|
|
|
|
href="https://github.com/livekit/components-js?ref=meet"
|
|
|
|
target="_blank"
|
|
|
|
rel="noreferrer"
|
|
|
|
>
|
|
|
|
GitHub
|
|
|
|
</a>
|
|
|
|
.
|
|
|
|
</footer>
|
|
|
|
</>
|
2022-10-24 17:03:12 +02:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Home;
|
|
|
|
|
|
|
|
function generateRoomId(): string {
|
|
|
|
return `${randomString(4)}-${randomString(4)}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
function randomString(length: number): string {
|
2023-01-19 19:56:00 +01:00
|
|
|
let result = '';
|
|
|
|
const characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
|
|
|
const charactersLength = characters.length;
|
|
|
|
for (let i = 0; i < length; i++) {
|
2022-10-24 17:03:12 +02:00
|
|
|
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|