API
DirectoryFast is built on the latest NextJs features, including the App router.
Structure
All your "backend" stuff is located in the /api
folder.
Any route.ts
file will be an API endpoint, and the folder route will be the final API route. You can define dynamic content as well:
folder | url |
---|---|
/api/products | /products |
/api/products/newest | /products/newest |
/api/products/[slug] | /products/the-best-product |
/api/category/[id]/products | /category/1337/products |
Calls
API calls are handled by Tanstack-Query, a powerful and simple library that handle cache, background updates or stale data out of the box.
GET example:
POST example:
Last updated