You might want to extend the functionality of your Latitude projects by using other npm packages.

Here’s how you can do it:


Install dependencies

You can install npm dependencies with a regular npm install command from the root of your project. Example:

npm install --save lodash

This will create a package.json file in your project root and add the dependency to it. The Latitude CLI will keep track of the dependencies you install and bundle them with your project.


Use your dependencies

Latitude views are a superset of Svelte’s template syntax. So you can use any JS dependency like you would in a Svelte component. Following our example:

    import { isNan } from 'lodash'

  {#if !isNan(1)}
    <p>Hello world</p>

Check out the examples section to see some use cases using third-party npm dependencies in Latitude projects.