Back to home

nextjs/

api

Version: 0.0.1

Last Updated: Unknown


NextJS - API route

Use this tempalate to create a simple NextJS route.

Required

VariableData TypeInfo
namestringThe name of the route file

Module files

1import { NextApiRequest, NextApiResponse } from "next";
2
3const handler = async (req: NextApiRequest, res: NextApiResponse) => {
4 try {
5 res.status(200).json({
6 message: "success",
7 });
8 } catch (err) {
9 res.status(500).json({ statusCode: 500, message: err.message });
10 }
11};
12
13export default handler;

Install


Lift generate


Repository

https://github.com/okeeffed/pkg-lift-nextjs

Sections