Guides
Frameworks - Tools

NextJS

6min

Introduction

You can use NextJS API paths to define and expose your mini-app and publish it on Vercel.

Next.js provides built-in API routes, making it an excellent choice for projects that combine frontend and backend functionality.

Initial Setup

Create a new Next.js project:

terminal


Install the SDK

npm
yarn


Open the project in your preferred editor. For example VSCode

terminal


Creating the Endpoint

Navigate to the pages/api/example folder and create a file named route.ts:

route.ts


Save the file and start the development server:

  • http://localhost:3000/api/example

Deploying to Production

  1. Deploy your project to Vercel
  2. One deployed, the metadata endpoint will be accesible at a URL like:
    1. https://your-domain.vercel.app/api/example

Catching Errors

In the example we have implemented a try-catch to catch any run-time errors. You can create an instance of all the errors that could occur during the execution of createMetadata.