Edge functions without netlify.toml

All of the documentation I have seen specifies that you to declare your edge functions in your netlify.toml file. Our website is 100% prebuilt files and is uploaded as a zip, rather than built upon deployment. We have been using _header and _redirect files instead of netlify.toml.

Is there an equivalent, maybe like _functions, that would contain declaration of edge functions or would we need to rewrite our _headers and _redirects into a new netlify.toml and use that.

1 Like

Hi @mrcycling

It is not possible to use Serverless Function, or Edge Functions with sites that are directly uploaded. To use either, you need to build on Netlify, or with Netlify CLI.

Thanks, but a bummer.

Kind leaves us with a limited choice, learn new technology or skip edge functions. But such is life :wink:

I’m a little confused. Even if you could upload Edge Functions directly, you’d still need to write and build them locally, so you’d still have to learn the new technology.

Edge functions are basically javascript, which I can muddle my way through.

I was referring to learning the various frameworks for building as opposed to using a traditional CMS such as MODX which I already understand.

Edge functions and the framework used to build a site are two completely separate things.

Yes I know they are different things. When I mentioned having to learn “new technology” I was referring to a framework that would allow Netlify to build our website, as opposed to our current zip upload method. Apologies if I wasn’t clear.

That’s still not true. As @coelmay has mentioned, Edge Functions have nothing to do with learning a framework.

Since you appear to be familiar with JavaScript, I’m assuming, Node.js and npm won’t be new technologies for you. If yes, then you can use Netlify CLI and deploy from the command line.

You can still push static files to Netlify without using a framework, by some settings in netlify.toml like:

[build]
  command = "echo Hi!"
  publish - "dist" # assuming you keep your website's files in dist directory

Actually Node, NPM, and command line are not tools I have used. I am not developer, rather I run a bicycle touring company and do coding only for our website. I am self-taught primarily what I need at that moment.

So Netlify can “build” even though I am uploading static files in a zip? Or does “build” require Netlify to pull those static files from somewhere such as GitHub or my server?

Well, as long as you can use Git, or learn to use it, this should still not be a problem.

You can simply upload your site to a Git repo and ask Netlify to build from that. You can use Netlify to directly publish the files from your Girt repo.

Simply add the toml file that I shared above. Move all your website’s files in the dist folder. Add your Edge Functions under Netlify/edge-functions directory, upload to Git, deploy from that repo.

To answer your specific question, yes Netlify needs to pull files from a Git repo in order to build.

Thanks. Looks like a learning curve no matter how I approach it. :nerd_face:

Can you use netlify.toml for build and edge, then keep _headers and _redirects? Or must they be merged?

Will have to look into changing our static page build script to upload to a git repo instead of Netlify.

You can keep it separate.