is it possible to write a route in NextJS using Golang?
Like the folder structure would be:
pages
api
And we can query /api/name and get a response back?
This is not something NextJS provides. But if you are hosting your page on Vercel, you can use their Go Runtime for Serverless Functions to achieve the same thing.
You can do this by having the file path be /api/name.go
instead of /pages/api/name.go
.