/nuxt-netlify-functions-example

Nuxt.js example for running Netlify functions locally in a dev environment and as a generated static site deployed to Netlify

Primary LanguageVueMIT LicenseMIT

nuxt-netlify-functions-example

Netlify Status

Nuxt.js example for running Netlify functions locally in a dev environment and as a generated static site deployed to Netlify.

Heavily inspired by the official guide and this example.

Demo

Live demo can be found here.

Info

For the requests on the client side we use the Axios Module. To proxy locally you have to set up the Proxy Module in nuxt.config.js:

proxy: {
  '/.netlify': {
    target: 'http://localhost:9000',
    pathRewrite: { '^/.netlify/functions': '' }
  }
}

Build Setup

# Use nvm
$ nvm use

# Install dependencies
$ yarn

# Build lambda functions locally
$ yarn netlify-lambda build netlify-lambda-src

# Serve lambda functions locally
$ yarn netlify-lambda serve netlify-lambda-src

# Serve nuxt app with hot reload at localhost:3000
$ yarn dev

# Generate static project
$ yarn generate