Netlify functions without connected Git repo

Can we use Netlify functions without connecting a site to Git?
How can I use Netlify functions if my build is handled in an external CI/CD service (and no need/willing to change)?
Can I “connect my site to a Git repo” (to benefit from Netlify functions) while disabling all Netlify build step and still have Netlify functions working?

I don’t believe you can take advantage of functions without a git repo - to my knowledge, they don’t work with drag n drop (that’s really only for very simple, static html + css sites).

You’ll need to trigger a deploy in order for your functions to get parsed, read, and become available for use, and that’s not possible without a repo.

You don’t necessarily need to use continous integration - you could push manually using the CLI, for example, but you will need a deploy.

I have a repo and I do CI/CD with a GitHub Action, which “manually” triggers a deploy on Netlify thanks to Netlify CLI, but the repo is not otherwise “connected/synced” to the Netlify site, and it seems the UI wants me to do so :
image

hm interesting, i’ve checked with some folks and this should work.

What happens when you manually trigger a deploy with. a repo that contains functions? does it work, as in, is your function detected and usable?

If not, you will need to set a functions directory via the netlify.toml file, as that is basically what the UI would do.

From our docs:

In the Netlify web interface, go to Settings > Functions and enter a path to the directory in your repository where your serverless functions will be stored. You can also set this by adding a functions field to your netlify.toml file. (Settings in netlify.toml override settings in the web interface.)

here is a working example by one of our engineers:

Ok it works when I set the --functions flag with netlify deploy in GitHub Actions. The UI misled me, I think it should say “(connect your site to a Git repository) or set your functions directory via CLI”, something like that.

Thanks for your help!

hi! can you point me to where it says the misleading thing? We can take a look and see if it can be clearer. thanks!

It is on the Functions screen:

image

If we click on the button “Connect to repository” then this screen appear:

Nowhere is mentioned in the UI that we can simply netlify deploy --functions=functions to get the same effect (that is to use Functions and see them in the UI).

thanks victor! I will bring it up to the team and we can see if there is a way to make this clearer.

Thanks again for the suggestion, Victor!

Hopefully this change to the wording makes it more obvious, but let us know if you have any further feedback :slight_smile:

Yes it’s clearer now :slight_smile: