Skip to content

Latest commit

 

History

History
37 lines (25 loc) · 626 Bytes

next.md

File metadata and controls

37 lines (25 loc) · 626 Bytes

Setting up Next.js

Credentials

In the root of your project, create a .env file and add your OpenAI API key:

OPENAI_API_KEY=sk-...

Install Beak.js for Next.js

npm install @beak/next --save
# or
yarn add @beak/next

Add the Beak.js handler

Create a new wildcard API route in pages/api/beak/[...path].ts:

import { beakHandler } from "@beakjs/next";

const handler = beakHandler();

export default handler;

Configure Beak to use the Next.js backend

const App = () => {
  return <Beak baseUrl="/api/beak">... your app code goes here</Beak>;
};