This is a Next.js project that uses express as a custom server. The server file is located at the root as server.js
.
First, install dependencies:
npm install
Add your OpenAI API key to the .env
file at root.
Next run
npm run dev-server
This will start the express server and the next app.
Open http://localhost:3000 with your browser to see the result.
There are two versions usage of the api from the custom server, a server-side rendered component that lives at http://localhost:3000/server-side and the homepage that uses a client-side component.
You can learn more about data fetching here: Next Data Fetching Documentation
Within the server
directory, you can update the service code that interacts with openai.
You can start editing the page by modifying app/page.js
. The page auto-updates as you edit the file.
This project uses next/font
to automatically optimize and load Inter, a custom Google Font.
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
- Express Guide - learn how to use express js.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!