Skip to content

Commit 086996a

Browse files
switch to express server with vite middleware
1 parent 44e4100 commit 086996a

9 files changed

+776
-1116
lines changed

README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@ npm run dev
2424

2525
This should start the console application on [http://localhost:3000](http://localhost:3000).
2626

27-
_Note:_ The `server.js` file uses [@fastify/vite](https://fastify-vite.dev/) to build and serve the React frontend contained in the [`/client`](./client) folder. You can find the configuration in the [`vite.config.js`](./vite.config.js) file.
27+
This application is a minimal template that uses [express](https://expressjs.com/) to serve the React frontend contained in the [`/client`](./client) folder. The server is configured to use [vite](https://vitejs.dev/) to build the React frontend.
28+
29+
This application shows how to send and receive Realtime API events over the WebRTC data channel and configure client-side function calling. You can also view the JSON payloads for client and server events using the logging panel in the UI.
30+
31+
For a more comprehensive example, see the [OpenAI Realtime Agents](https://github.com/openai/openai-realtime-agents) demo built with Next.js, using an agentic architecture inspired by [OpenAI Swarm](https://github.com/openai/swarm).
2832

2933
## Previous WebSockets version
3034

31-
The previous version of this application that used WebSockets on the client (not recommended in client-side browsers) [can be found here](https://github.com/openai/openai-realtime-console/tree/websockets).
35+
The previous version of this application that used WebSockets on the client (not recommended in browsers) [can be found here](https://github.com/openai/openai-realtime-console/tree/websockets).
3236

3337
## License
3438

client/entry-client.jsx

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { StrictMode } from "react";
2+
import ReactDOM from "react-dom/client";
3+
import App from "./components/App";
4+
import "./base.css";
5+
6+
ReactDOM.hydrateRoot(
7+
document.getElementById("root"),
8+
<StrictMode>
9+
<App />
10+
</StrictMode>,
11+
);

client/entry-server.jsx

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { StrictMode } from "react";
2+
import { renderToString } from "react-dom/server";
3+
import App from "./components/App";
4+
5+
export function render() {
6+
const html = renderToString(
7+
<StrictMode>
8+
<App />
9+
</StrictMode>,
10+
);
11+
return { html };
12+
}

client/index.html

+3-14
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,11 @@
88
<link rel="icon" href="/assets/openai-logomark.svg" />
99
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
1010
<link rel="stylesheet" href="/base.css" />
11-
<link
12-
rel="stylesheet"
13-
href="https://unpkg.com/[email protected]/dist/leaflet.css"
14-
integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ=="
15-
crossorigin=""
16-
/>
17-
<script
18-
src="https://unpkg.com/[email protected]/dist/leaflet.js"
19-
integrity="sha512-gZwIG9x3wUXg2hdXF6+rVkLF/0Vi9U8D2Ntg4Ga5I5BZpVkVxlJWbSQtXPSiUTtC0TjtGOmxa1AJPuV0CPthew=="
20-
crossorigin=""
21-
></script>
2211
<!-- head -->
2312
</head>
2413
<body>
25-
<div id="root"><!-- element --></div>
14+
<div id="root"><!--ssr-outlet--></div>
15+
<!-- hydration -->
16+
<script type="module" src="./entry-client.jsx"></script>
2617
</body>
27-
<!-- hydration -->
28-
<script type="module" src="/:mount.js"></script>
2918
</html>

0 commit comments

Comments
 (0)