Skip to content

Commit 7d934ff

Browse files
authored
Update next example to next v14 (#996)
1 parent 6ef4005 commit 7d934ff

16 files changed

+134
-133
lines changed

examples/nextjs/.eslintrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"extends": "next/core-web-vitals"
2+
"extends": ["next", "next/core-web-vitals"]
33
}

examples/nextjs/next.config.js renamed to examples/nextjs/next.config.cjs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// @ts-check
2+
13
/** @type {import('next').NextConfig} */
24
const nextConfig = {
35
reactStrictMode: true,

examples/nextjs/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "@livekit/component-example-next",
33
"version": "0.2.40",
44
"private": true,
5+
"type": "module",
56
"scripts": {
67
"dev": "next dev",
78
"build": "next build",
@@ -14,7 +15,7 @@
1415
"@livekit/track-processors": "^0.3.2",
1516
"livekit-client": "^2.5.4",
1617
"livekit-server-sdk": "^2.6.1",
17-
"next": "^12.3.4",
18+
"next": "^14.2.13",
1819
"react": "^18.2.0",
1920
"react-dom": "^18.2.0"
2021
},

examples/nextjs/pages/_app.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import '../styles/globals.css';
2-
import type { AppProps } from 'next/app';
2+
import type { AppProps } from 'next/app.js';
33
import '@livekit/components-styles';
44

55
function MyApp({ Component, pageProps }: AppProps) {

examples/nextjs/pages/audio-only.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use client';
2+
13
import { AudioConference, LiveKitRoom, useToken } from '@livekit/components-react';
24
import type { NextPage } from 'next';
35
import { generateRandomUserId } from '../lib/helper';

examples/nextjs/pages/clubhouse.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use client';
2+
13
import {
24
ControlBar,
35
LiveKitRoom,

examples/nextjs/pages/customize.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use client';
2+
13
import {
24
LiveKitRoom,
35
ParticipantName,

examples/nextjs/pages/e2ee.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use client';
2+
13
import { LiveKitRoom, useToken, VideoConference, setLogLevel } from '@livekit/components-react';
24
import type { NextPage } from 'next';
35
import * as React from 'react';

examples/nextjs/pages/index.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
'use client';
2+
13
import type { NextPage } from 'next';
2-
import Head from 'next/head';
34
import styles from '../styles/Home.module.scss';
5+
import Head from 'next/head';
46

57
const EXAMPLE_ROUTES = {
68
voiceAssistant: {

examples/nextjs/pages/minimal.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
'use client';
2+
13
import { LiveKitRoom, useToken, VideoConference, setLogLevel } from '@livekit/components-react';
2-
import { RoomConnectOptions } from 'livekit-client';
34
import type { NextPage } from 'next';
45
import { generateRandomUserId } from '../lib/helper';
56
import { useMemo } from 'react';

examples/nextjs/pages/processors.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use client';
2+
13
import * as React from 'react';
24
import { setLogLevel } from '@livekit/components-core';
35
import {

examples/nextjs/pages/simple.tsx

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1+
'use client';
2+
13
import {
24
ConnectionState,
35
ControlBar,
46
GridLayout,
57
LiveKitRoom,
68
ParticipantTile,
9+
RoomAudioRenderer,
710
RoomName,
811
TrackRefContext,
912
useToken,
1013
useTracks,
1114
} from '@livekit/components-react';
1215
import { Track } from 'livekit-client';
1316
import type { NextPage } from 'next';
14-
import { useEffect, useState } from 'react';
17+
import { useMemo, useState } from 'react';
1518
import styles from '../styles/Simple.module.css';
1619
import { generateRandomUserId } from '../lib/helper';
1720

@@ -22,12 +25,14 @@ const SimpleExample: NextPage = () => {
2225
const [connect, setConnect] = useState(false);
2326
const [isConnected, setIsConnected] = useState(false);
2427

25-
const [userInfo] = useState({
26-
userInfo: {
27-
identity: userIdentity,
28-
name: userIdentity,
29-
},
30-
});
28+
const userInfo = useMemo(() => {
29+
return {
30+
userInfo: {
31+
identity: userIdentity,
32+
name: userIdentity,
33+
},
34+
};
35+
}, []);
3136

3237
const token = useToken(process.env.NEXT_PUBLIC_LK_TOKEN_ENDPOINT, roomName, userInfo);
3338

@@ -58,7 +63,7 @@ const SimpleExample: NextPage = () => {
5863
>
5964
<RoomName />
6065
<ConnectionState />
61-
{/* <RoomAudioRenderer /> */}
66+
<RoomAudioRenderer />
6267
{isConnected && <Stage />}
6368
<ControlBar />
6469
</LiveKitRoom>

examples/nextjs/pages/voice-assistant.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use client';
2+
13
import {
24
LiveKitRoom,
35
useToken,

examples/nextjs/tsconfig.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"compilerOptions": {
3-
"target": "es5",
3+
"target": "es6",
44
"lib": ["dom", "dom.iterable", "esnext"],
55
"allowJs": true,
66
"skipLibCheck": true,
77
"strict": true,
88
"forceConsistentCasingInFileNames": true,
99
"noEmit": true,
1010
"esModuleInterop": true,
11-
"module": "esnext",
12-
"moduleResolution": "node",
11+
"module": "ES2020",
12+
"moduleResolution": "Bundler",
1313
"resolveJsonModule": true,
1414
"isolatedModules": true,
1515
"jsx": "preserve",
@@ -21,6 +21,6 @@
2121
"@livekit/components-styles": ["../../packages/styles/dist/types/general/index.css.d.ts"]
2222
}
2323
},
24-
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
24+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "next.config.cjs"],
2525
"exclude": ["node_modules"]
2626
}

packages/react/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
],
4040
"scripts": {
4141
"build": "pnpm gen:svg && vite build",
42-
"dev": "tsup --watch --onSuccess \"tsc --declaration --emitDeclarationOnly\"",
42+
"dev": "vite build --watch",
4343
"gen:icons": "rimraf -I -g ./src/assets/icons/*Icon.tsx && svgr --template ./src/assets/template.js --out-dir ./src/assets/icons --typescript ../styles/assets/icons",
4444
"gen:images": "rimraf -I -g ./src/assets/images/*.tsx && svgr --template ./src/assets/template.js --out-dir ./src/assets/images --typescript --no-svgo ../styles/assets/images",
4545
"gen:svg": "pnpm gen:images && pnpm gen:icons",

0 commit comments

Comments
 (0)