2022-02-22 01:01:21 -05:00
2022-02-22 00:57:00 -05:00
2022-02-21 23:23:37 -05:00
2022-02-03 13:08:10 -05:00
2022-02-03 13:08:10 -05:00
2022-02-03 13:08:10 -05:00
2022-02-03 13:08:10 -05:00
2022-02-21 11:43:00 -05:00
2022-02-03 13:08:10 -05:00
2022-02-03 13:08:10 -05:00
2022-02-21 11:43:00 -05:00
2022-02-03 13:08:10 -05:00
2022-02-03 13:08:10 -05:00
2022-02-03 13:08:10 -05:00
2022-02-21 15:55:33 -05:00

Nuxt Toolbox Template

Build Setup

# install dependencies
$ npm install

# serve with hot reload at localhost:3000
$ npm run dev

# build for production and launch server
$ npm run build
$ npm run start

# generate static project
$ npm run generate

Deploy to Netlify


Want to deploy immediately? Click this button

Deploy to Netlify Button

To deploy using the Netlify cli:

npm install netlify-cli -g # to install the Netlify CLI tool globally
netlify init # initialize a new Netlify project & deploy

It will use the information from the included Netlify configuration file, netlify.toml, to set up the build command as npm run generate to create a static project and locate the build project in the dist directory.

The init process will also set up continuous deployemnt for your project so that a new build will be triggered & deployed when you push code to the repo (you can change this from your project dashboard: Site Settings/Build & deploy/Continuous Deployment).

You can also use netlify deploy (--prod) to manually deploy and netlify open to open your project dashboard.

💡 we only have so many keystrokes to give, use ntl shorthand for netlify or make an alias of your own to save hours...of accumulated miliseconds

Running Locally

You can use netlify dev from the command line to access project information like environment variables as well as

  • test functions
  • test redirects
  • share a live session via url with netlify dev --live
  • and more :)

Deployment Resources

Redirects


In the netlify.toml configuration file there is an example of how to implement redirects. Redirects can be used to do many things from redirecting Single Page Apps more predictably, redirecting based on country/language to leveraging On-Demand Builders for Distributed Persistant Rendering.

In the example we'll be using redirects to have a shorter endpoint to Netlify functions. By default, you call a Netlify function when requesting a path like https://yoursite.netlify.com/.netlify/functions/functionName. Instead, we'll redirect all calls from a path including /api to call on the Netlify functions. So the path will be https://yoursite.netlify.com/api/functionName, a lot easier to remember too.

Example

[[redirects]]
from = "/api/*"
to = "/.netlify/functions/:splat"
status = 200
force = true

First we create a section in the .toml for the redirect using [[redirects]]. Each redirect should have this line to start the redirect code, and the redirects will be executed in the order they appear in the .toml from top to bottom.

The bare minimum needed is the from and to, letting the CDN know when a route is requested, the from, forward it on to another path, the to. In the example, we also added an 'Ok' status code, 200, and set the force to true to make sure it always redirects from the from path.

There are many ways to use redirects. Check out the resouces below to learn more.

Redirect Resources

Description
No description provided
Readme 1.5 MiB
Languages
HTML 33.2%
JavaScript 32.8%
CSS 20.8%
Vue 13.2%