How was your year on Netlify? Get your own personalized summary! Your Year on Netlify

Guides & Tutorials

Serverless functions made simple - Just add files

Guides & Tutorials

Serverless functions made simple - Just add files

Throughout December we'll be highlighting a different Netlify feature each day. It might just be the thing you need to unlock those creative juices, and dust off that domain you registered but never deployed! Keep an eye on the blog and on Twitter for each feature!

Once upon a time, if you needed a back-end for your web project you'd have to get yourself a server. Or perhaps a virtual server. Either way, you were in for some configuration and maintenance. Maintenance which would last forever.

These days we can use serverless functions to provide back-end services for our projects. And so, with a little JavaScript, we can deliver a full stack of capabilities without having to learn the entire spectrum of skills necessary to truly be a full-stack developer. (From browser APIs to OS security patches, via DBA skills, tap dancing, and everything in between)

But building, deploying, and versioning serverless functions can be tricky, right? No, not these days. We got you!

Netlify Functions adds an entire serverless development and deployment pipeline to your project as part of your existing workflow.

How to add serverless functions to your project

All you need to do is add a file containing your functions to a netlify/functions folder in your project directory, and push them to your project repo. That's it.

When you do that, your functions (and any dependencies) will be packaged up, deployed to AWS Lambda, and all of their configuration will be taken care of, resulting in serverless functions with URLs relative to your project's root. No need for an AWS account. No need to leave your code.

Done.

Accessing your functions

How you name your function files determines the URL that they get.

By default, a file called random-joke.js will be served up at the URL https://your-project.domain/.netlify/functions/random-joke

But you can configure this in order to have complete control over your URL design.

Deploying updates and rolling back to previous versions of your serverless functions happens just the same as with the rest of your code. They are part of the same codebase and benefit from all of the same workflow tools as the rest of your site.

Try it

Screenshot of an example, "hello world" site

Here's a simple example site to explore. You can make a copy and deploy it to Netlify with just a couple of clicks. Try it out by clicking the Deploy to Netlify button below.

Deploy to Netlify

More information

Keep reading

Recent posts

Book cover with the title Deliver web project 10 times faster with Jamstack enterprise

Deliver web projects 10× faster

Get the whitepaper