React remix api route

372 Views Asked by At

How to create an api route which is inside a api folder. I want to separte my view and api files. Here api>users.js (api/users) is not working. But if i create a file name api.users.js (api/users) inside routes it works and also the api>index.js (/api). I need to keep my api files in a folder.

enter image description here

1

There are 1 best solutions below

0
On BEST ANSWER

Remix v2 flat files convention prevents you from using folders for nested routes. It only supports folders for colocation.

You can switch back to the v1 convention using the package @remix-run/v1-route-convention

https://github.com/remix-run/v1-compat-utils/tree/main/packages/v1-route-convention