How to import "Routes" from another file into Main.wasp? If possible.
Hi guys,
I'm looking for a way to define Routes in Wasp in a separate file (myroutes.wasp) and then import them into Main.wasp but I can't find anything from the documentation.
Does anyone have a suggestion or a solution?
Thanks!
6 Replies
Hi @mario.p. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Wohooo @mario.p, you just became a Waspeteer level 1!
----------------------
Unfortunately, based on the provided knowledge sources, it is currently not possible to import routes from a separate file into
main.wasp
in Wasp. The ability to split the main.wasp
file into multiple files or modules is a planned feature but not yet implemented.
Several sources confirm this:
1. Discord support thread mentions that this feature is not available at the moment but is planned for future updates.
2. Another Discord thread confirms that splitting the main.wasp
file is a feature they'll be tackling next, but it's not currently possible.
3. A Github issue discusses future plans for supporting multiple Wasp files/modules, but this is not yet implemented.
For now, all routes and other declarations need to be defined in the single main.wasp
file. The Wasp team is aware that this file can grow large as applications become more complex, and they are working on a solution to allow for more modular file organization in future versions.
If you're concerned about the main.wasp
file becoming too large or difficult to manage, you might want to follow the Github discussions or join the Discord community to stay updated on when this feature becomes available.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @mario.p, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?yeah it's not possible in old format, but you should be able to split wasp ts files
Hey @mario.p, Fecony is right.
You can't do it with
*.wasp
files, and we'll soon introduce official support for doing it with *.wasp.ts
files. This is the new TS spec (docs here).
That said, some users have already started experimenting with it and it seems to work. Check this out if you're interested in trying out multiple Wasp files with the new TS spec: https://discord.com/channels/686873244791210014/1216264399552122922/1313807076404756541
But beware, this is not yet officialy supportedThank you both, guys!