New netlify functions:invoke command in CLI

I just realized i added [feature] add functions:invoke command by sw-yx · Pull Request #213 · netlify/netlify-dev-plugin · GitHub but didnt do much publicity

Locally Testing Functions with netlify functions:invoke

netlify functions:invoke allows you to locally test functions going above and beyond a simple GET request in browser. (we only model POSTs now but could easily expand from here).

If you have Netlify Dev running your functions, you can then test sending payloads of data, or authentication payloads:


# with prompting
netlify functions:invoke # we will prompt you at each step
netlify functions:invoke myfunction # invoke a specific function
netlify functions:invoke --name myfunction # invoke a specific function

# no prompting (good for CI)
netlify functions:invoke --name myfunction --identity # invoke a specific function with netlify identity headers
netlify functions:invoke --name myfunction --no-identity # invoke a specific function without netlify identity headers

# sending payloads
netlify functions:invoke myfunction --payload '{"foo": 1}'
netlify functions:invoke myfunction --querystring "foo=1"
netlify functions:invoke myfunction --payload "./pathTo.json"

There are special cases for event triggered functions (eg identity-signup) which will also give you mock data for testing. This makes manual local testing of event triggered functions possible, which drastically improves the development experience.

This is a new feature; ideas and feedback and issues and PR’s welcome! docs here: netlify-dev-plugin/README.md at master · netlify/netlify-dev-plugin · GitHub

1 Like

Can this be used to invoke remote functions instead of just local ones?

Hi @Simone_Scarduzio,

No. It can only be used to functions in Netlify CLI. The remote functions can be invoked by visiting their endpoint.

1 Like