nextjs-vip
v1.0.21
Published
Simple and streamlined, built as a helper library for the [Nextjs](https://nextjs.org) library
Downloads
12
Readme
nextjs-vip
Simple and streamlined, built as a helper library for the Nextjs library
The library is under development, and if there are any problems or comments, please submit them on github issues
npm i nextjs-vip
More in the documentation
Project structure
API
This library was built solely for use in API Routes because it is built to improve developer experience and bring the express.js code structure to nextjs API Routes. You can write them within API Routes files
syntx
let app = new API(req, res)
app.get(auth: Boolean ,callback: fun)
// or
app.get(callback: fun)
example
import API from "nextjs-vip"
export default async function API_Send(req, res, next) {
let app = new API(req, res)
app.get(async () => {
// send data
// format JSON
app.Send(data)
})
}
| name method | syntx | | ----------- | ----------------------- | | get | get(auth? ,callback) | | post | post(auth? ,callback) | | put | put(auth? ,callback) | | delete | delete(auth? ,callback) | | patch | patch(auth? ,callback) | | all | all(auth? ,callback) |
sitemap
Create a site map automatically
syntx
// data example
let data =[
{url:"http://example.com/132",lastmod:"2023-11-4"},
{url:"http://example.com/131",lastmod:"2023-11-3"}
]
sitemap(res, data)
example
// file: sitemap.xml.js
// imports
import sitemap from "nextjs-vip/sitemap"
export async function getServerSideProps({ res }) {
const request = await fetch(process.env.NEXT_PUBLIC_API)
const data = await request.json()
// generate sitemap.xml
sitemap(res, data)
return { props: {} }
}
export default function s() { }