Installation

Learn how to install Spruce in your application.

Methods

There are 2 different ways of installing Spruce.

  1. CDN (recommended)

  2. NPM / Yarn

To install Spruce using a CDN, include the following <script> tag add the end of your <body>:

<script src="https://cdn.jsdelivr.net/npm/@ryangjchandler/spruce@2.x.x/dist/spruce.umd.js"></script>

If you followed Alpine's installation instructions, the Alpine script should be in the <head> of your document, with a defer attribute.

You do not need to manually initalise Spruce when installing it via the CDN.

NPM / Yarn

To install Spruce using NPM / Yarn, run the following command inside of your project:

npm install @ryangjchandler/spruce

yarn add @ryangjchandler/spruce

Inside of your JavaScript file, add the following code:

import '@ryangjchandler/spruce'

Transpile your JavaScript file and include it in your page.

When using this installation method, it's also recommended that you install Alpine in the same way. Visit the installation instructions for Alpine for more information.

Spruce must be included before Alpine to ensure it is initialised before Alpine.

Last updated