🌲
Spruce
  • Introduction
  • Installation
  • Quick Start
  • The Essentials
  • Stores
  • Watchers
  • Persistence
  • Advanced
    • Hooks
  • Examples
    • Global Toast System
  • More
    • GitHub
    • Funding
    • Security
    • License
Powered by GitBook
On this page
  • Methods
  • NPM (recommended)
  • NPM / Yarn

Was this helpful?

Installation

Learn how to install Spruce in your application.

PreviousIntroductionNextQuick Start

Last updated 4 years ago

Was this helpful?

Methods

There are 2 different ways of installing Spruce.

  1. CDN (recommended)

  2. NPM / Yarn

NPM (recommended)

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 , 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.

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

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

installation instructions
installation instructions