Netlify functions cant be organized into folders? How could I ever build a big backend?

@perry Hello, am I missing something here? I’ve been at this for some time, and I came across this post:

So according to Dennis at the end, the only way is to have the directory have the same name as the js file? How could I ever build a large app? Am I just supposed to have hundreds functions in the functions folder? This would be a total deal breaker if so. Please help.

PLEASE help us help you by writing a good post!

  • we need to know your netlify site name. Example:
  • DNS issues? Tell us the custom domain, tell us the error message! We can’t help if we don’t know your domain.
  • Build problems? Link or paste the FULL build log & build settings screenshot

The better the post - the faster the answer.

Hi @chrisleeharris,

Maybe I’m not understanding your question, but you can have multiple functions with each one in it’s own folder under your functions folder. The caveat is the main entry file needs to be the same name as the folder name during the deploy, so the build bots know how to bundle up each function.


    ├── parts
    ├── employees

How could I ever build a large app? Am I just supposed to have hundreds functions in the functions folder?

The idea of using Netlify lambda functions is to be able to have an easy way to create lambda functions for your serverless app. This would have the same limitations for any serverless application using AWS lambda functions since Netlify functions are lambdas on the aws platform. The idea of lambda functions is to keep them simple and focused.

If you need a backend with a large database you might want to consider a serverless solution like FaunaDB or MongoDB to accomplish your needs. In some use cases you might not be able to use a serverless architecture and would need to research where your use case falls into.

@talves thank you. My real question is, if every folder can only have one function, then if we are building a backend with 100 different functions, then we will have a function folder with 100 folders? We cant group them into related folders? Let’s say, five different folders? It just seems like if I did that one the front end, with 100 pages, how could that ever be organized and how could I ever know where I was?

Although Netlify doesn’t handle that for you, you could put together your own build step to handle the bundling of the files from your source location into the functions folder as part of your build step.

@talves ok, so basically if I want to structure my backend folders any way I want, I can, but then I just need to make a build script to put them in the main folder? and that would handle all dependencies and everything?

Yes. BUT are you talking about these folders being static web pages or are they actual api called functions that have the page data?

api functions. They will take data from a form on the front-end web site, then send them somewhere else through an API. Thats ok right? Also they will need to access databases to get user information

Absolutely, but this throws some flags up for me, because having hundreds of them means you are making api calls for each page that might only need one function in a lot of cases. Not sure your level of knowledge and don’t want you to go down a rabbit hole without knowing the ramifications of calling lambdas on each event trigger.

When I have a lot of calls for data, I would start looking toward a more structured solution using a serverless database rather than trying to rely on a full set of lambdas to manage.

@talves ok. I have never built a backend, and I just assumed it would require a lot of files, maybe I’m wrong. Basically the website is a loan form then I will need to send the data somewhere else to process it, then receive data back when that process is done. And do that a few times during the application, and for different kinds of loans. Is this suitable for netlify?

This type of solution is ok on Netlify for sure, but using lambdas for a full app solution will be more expensive and harder to manage than let’s say a more structured solution like a serverless SaaS database solution to handle the data for you. You would then use Netlify to handle the client static site and the client would talk to the api for auth/data connectivity.

An example would be a React application built to talk to the Firebase/Firestore database which has user auth and connectivity built into the connection.

@talves Ok so with the react app, I wouldnt be using lambda functions? I’ve never build a react app or JAMstack so I’m kind of struggling to know which direction I should go. Basically I have built smart contracts on the IBM blockchain platform (they store the data with CouchDB). The front end will be a loan application (I used gridsome, maybe this was wrong I dont know, I only have a form), then I will take that data and then submit it to the IBM blockchain console. In the console there are contracts that will also call API’s. Then that contract will send data back to me. I dont know if I should use lambda functions or react with express or anything I’m new to this. So I’ve been on lambda functions for about a week and a half but am I going in the wrong direction? Thank you so much for your help

here is the flow of how it is supposed to work

They provide the functions and the SDK to connect to the platform, im just struggling to know how I should send my data to their SDK

No problem. I’m not sure whether you are going in the right or wrong direction, because it takes a lot of time to analyze a project’s requirements and give a recommended solution on any platform. With this or any solution, if you are going to do this on your own and you don’t have the knowledge of the platforms, I recommend you to start with a very small proof of concept before you go too far to save yourself time in the long run.

Good luck in your research!

alright thanks for your help!

1 Like