Dynamically fetching routes
Unanswered
Spectacled Caiman posted this in #help-forum
Spectacled CaimanOP
Is there a way for me to get all the routes that my project has? I am building a site for a client and their website has a bunch routes, and it can get really long. I want to make a sitemap.xml (but have it in the sitemap.ts file) is there a way to get all my registered routes dynamically and use them like that or do I have to manually type out every single route?
2 Replies
Common paper wasp
I highly not recommend you to do that, better follow the doc and generate a sitemap by yourself: https://nextjs.org/docs/app/api-reference/file-conventions/metadata/sitemap
But anyway take into account that you are using node.js and basically have all required access to directories using node.js fs module, so you can read app or pages (whatever you are using in your project) directories recursively and get all info you need.
But anyway take into account that you are using node.js and basically have all required access to directories using node.js fs module, so you can read app or pages (whatever you are using in your project) directories recursively and get all info you need.
Spectacled CaimanOP
Alright thank you sir I will generate them by hand :)