CSS / JavaScript
Learn how to customize the CSS and JavaScript of your Nova application.
When building custom Nova tools, resource tools, cards, and fields, you may use a variety of helpers that are globally available to your JavaScript components.
Nova Requests
You may use the Nova.request()
method to make XHR requests to backend routes provided by your application or custom tools, cards, and fields. The Nova.request()
method is powered by Axios and offers the same API. However, the Nova.request()
method configures its own instance of Axios that has pre-configured interceptors to properly handle and redirect on 401
, 403
, and 500
level HTTP server responses:
Manual Navigation
The global Nova
JavaScript object offers a visit
method that may be invoked to navigate to other URLs within your Nova dashboard:
The visit
method accepts an array of navigation options as its second argument. As the visit
method uses Inertia’s own visit
method behind the scenes, all of Inertia’s visit
options are supported by Nova’s visit
method:
Event Bus
The global Nova
JavaScript object may be used as an event bus by your custom components. The bus provides the following methods, which correspond to and have the same behavior as the event methods provided by tiny-emitter:
Notifications
You may display toast notification to users of your custom frontend components by calling the success
, error
, info
, or warning
methods on the global Nova
object:
Shortcuts
Nova provides two convenience methods for managing keyboard shortcuts, powered by Mousetrap. You may use these methods within your custom components to register and unregister shortcuts:
Global Variables
The global Nova
JavaScript object’s config
method allows you to get the current Nova base
path and userId
configuration values:
However, you are free to add additional values to this object using the Nova::provideToScript
method. You may call this method within a Nova::serving
listener, which should typically be registered in the boot
method of your application or custom component’s service provider:
Once the variable has been provided to Nova via the provideToScript
method, you may access it using the global Nova
JavaScript object’s config
method:
Localizations
Localization strings can be passed to the frontend via your NovaServiceProvider
. To learn more, please consult the full custom localization documentation.
Using Nova Mixins
Custom Nova tools, resource tools, cards, and other custom packages that are being developed within a nova-components
directory of a Laravel application can reference Nova’s own packages.js
file by defining a laravel-nova
alias that points to this file within the Nova installation that is located within your root application’s vendor
directory. This alias should be placed in your package’s nova.mix.js
:
Custom Nova packages that are developed outside of a nova-components
directory should declare laravel/nova
as a “dev” Composer dependency. Then, define a laravel-nova
Mix alias that points to the packages.js
file within your custom package’s vendor
directory:
In order to compile custom packages assets with laravel-nova
mixins you are required to prepare laravel/nova
’s node_modules
by running the following command:
Laravel Nova’s assets are built using lockfile version 3
and require NPM 9+.
Vue DevTools
By default, Nova’s JavaScript is compiled for production. As such, you will not be able to access the Vue DevTools out of the box without compiling Nova’s JavaScript for development. To accomplish this, you may issue the following terminal commands from the root of your Nova project:
Please note, compiling Nova’s assets for production purposes is not supported.