#ignore folder name in api
7 messages · Page 1 of 1 (latest)
Hi @remote talon. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
There isn’t currently a supported way to “hide” a folder name from the generated api path (for example, to have files under convex/features/users.ts show up as api.users.* instead of api.features.users.*).
Convex’s codegen uses the folder and file path inside the Convex functions directory directly to determine the API path — whatever comes after api. mirrors that path, and there’s no configuration for collapsing or ignoring intermediate folders like features or (group) folders. [Feature management; Different root folders]
Related ideas have been discussed (e.g. ignoring bracketed folders like (internal) or (loyalty)), but staff have confirmed these are not features today, just potential future improvements. [Feature request: better file management; Bracket folders discussion]
So right now your options, within what’s documented, are:
- Put
users.ts,organizations.ts, etc. directly underconvex/if you needapi.users.*andapi.organizations.*. - Or accept
api.features.users.*if you keep them underconvex/features/.
There’s no convex.json or .convexignore setting that changes this mapping today. [convex.json config]
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@remote talon Kapa.ai is still learning and improving, please let me know how I did by reacting below.
So if I do this (#1341424905299693588 message) on the front end then I can just call it as myApi.organizations? @random saffron
Let me check the knowledge base for you again. One moment! :books:
Yes.
In that thread, support suggested exactly this pattern on the frontend:
// frontend
const myApi = api.functions;
This works because api.functions is just a sub-tree of the full Convex API object. [Different root folders]
Applied to your case:
-
Suppose your Convex files are under
convex/features/organizations.ts, so you normally callapi.features.organizations.someFn. -
On the frontend you can alias:
import { api } from "../convex/_generated/api"; const myApi = api.features; -
Now you can call
myApi.organizations.someFninstead ofapi.features.organizations.someFn.