DEV Community

Cover image for Serverless functions made simple - Just add files
Phil Hawksworth for Netlify

Posted on • Originally published at netlify.app

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

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay