diff --git a/pages/index.tsx b/pages/index.tsx index 3e82e32..2ffa2a6 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,4 +1,4 @@ -import type { NextPage } from 'next'; +import type { NextPage, GetServerSideProps, InferGetServerSidePropsType } from 'next'; import { useRouter } from 'next/router'; import React, { ReactElement, useCallback, useEffect, useState } from 'react'; import styles from '../styles/Home.module.css'; @@ -85,31 +85,21 @@ function CustomConnectionTab({ label }: { label: string }) { ); } -const Home: NextPage = () => { +export const getServerSideProps: GetServerSideProps<{ tabIndex: number }> = async ({ + query, + res, +}) => { + res.setHeader('Cache-Control', 'public, max-age=7200'); + const tabIndex = query.tab === 'custom' ? 1 : 0; + return { props: { tabIndex } }; +}; + +const Home = ({ tabIndex }: InferGetServerSidePropsType) => { const router = useRouter(); - const [tabIndex, setTabIndex] = useState(0); - const { tab } = router.query; - - useEffect(() => { - if (tab === 'custom') { - setTabIndex(1); - } else { - setTabIndex(0); - } - }, [tab]); - - const onTabSelected = useCallback((index: number) => { - setTabIndex(index); + function onTabSelected(index: number) { const tab = index === 1 ? 'custom' : 'demo'; - router.push( - {}, - { query: { tab } }, - { - shallow: true, - }, - ); - }, []); - + router.push({ query: { tab } }); + } return ( <>
diff --git a/public/images/livekit-meet-home.svg b/public/images/livekit-meet-home.svg index 687926e..3523386 100644 --- a/public/images/livekit-meet-home.svg +++ b/public/images/livekit-meet-home.svg @@ -1,13 +1 @@ - - - - - - - - - - - - - + \ No newline at end of file diff --git a/public/images/livekit-safari-pinned-tab.svg b/public/images/livekit-safari-pinned-tab.svg index 0d08c93..b6f5e62 100644 --- a/public/images/livekit-safari-pinned-tab.svg +++ b/public/images/livekit-safari-pinned-tab.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file