#

# JavaScript


The following statement will copy and keep synced the JavaScript files in your own app/javascripts dir (or any dir you want use).

javascript_dir = Rails.root.join('app/javascripts')
Pagy.sync_javascript(javascript_dir, 'pagy.mjs', 'pagy.min.js') if Rails.env.development?

After that you should treat the files as your own, according to the configuration used by your app. For example:

application.js
import Pagy from "pagy.mjs"

You can use load, turbo:load, turbolinks:load, or any appropriate event to init the pagy *_js helpers. For example:

window.addEventListener("load", Pagy.init)