Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Nova Scroll Top Laravel Package

tanmuhittin/nova-scroll-top

A lightweight Laravel Nova package that adds a configurable scroll-to-top button to long pages, resource indexes, and lists, helping users quickly return to the top without manual scrolling. Easy to install and customize for a smoother Nova browsing experience.

View on GitHub
Deep Wiki
Context7

Getting Started

Install

composer require tanmuhittin/nova-scroll-top

The package is a single-purpose Nova asset package: its service provider registers one small JavaScript file with Nova::script(), and that script scrolls the window back to the top whenever Nova navigates between routes (index → detail, detail → edit, resource → related resource, etc.).

Where to look first

  1. composer.json → extra.laravel.providers. If the provider is listed, Laravel auto-discovery registers it and you're done. If your project uses "don't-discover", add it to config/app.php manually.
  2. The service provider in src/ — it's a few dozen lines. Look for a boot() containing Nova::script('nova-scroll-top', ...) or Nova::style(...).
  3. The compiled JS in dist//resources/js/ — that's the entire behavior. Read it once so you know exactly which event it hooks and whether it scrolls unconditionally.

First use case to validate

Pick your longest resource index page. Scroll halfway down, click into a record. Before the package: the detail view opens already scrolled (a long-standing Nova annoyance on long pages). After: you land at the top. Hard-refresh first so the new asset is loaded, then repeat the scroll-and-click test on at least two navigation types (resource → detail, and detail → related resource) to confirm the hook fires on both.

If you're on a cached-config deployment, run php artisan config:clear and php artisan optimize:clear after install.

Implementation Patterns

Zero-config, global behavior. There's nothing to wire per page. Once the provider is registered, every Nova route change scrolls to top. Do not add it to individual tools or cards — it's app-wide by design.

Vendor it if you need nuance. This package is essentially one file, last released in 2020, with 22 stars. For most teams the pragmatic pattern is to copy the behavior into your own Nova asset and drop the dependency, so you own the compatibility with your Nova version and can add conditions:

// app/Providers/NovaServiceProvider.php  boot()
Nova::script('scroll-top', __DIR__.'/../Nova/scroll-top.js');
// app/Nova/scroll-top.js — verify the event name against the package's dist file
Nova.booting(() => {
    Nova.$on('nova-navigated', () => {
        if (!window.location.hash) {                      // don't fight anchor links
            window.scrollTo({ top: 0, left: 0, behavior: 'instant' });
        }
    });
});

If the event the package hooks isn't reliable on your Nova version, a version-proof fallback is to wrap history.pushState/replaceState and scroll on the wrapped calls.

Pair it with anchor/hash-based tools. If you use a Nova tool that deep-links to a section via #hash, an unconditional scroll-to-top will land the user at the top and ignore the anchor. That's the most common reason to fork or vendor rather than consume the package as-is.

Don't mix with scroll restoration. If a specific Nova screen wants "return to where I was" (long index with back-navigation, or an infinite-scroll table), the two behaviors conflict. Scope the scroll-to-top out on those routes at the JS level rather than trying to configure the package.

Non-Nova surfaces are out of scope. For Inertia/SPA admin panels, use your router's afterEach hook instead. This package only knows about Nova's navigation events.

Custom themes / nested scroll containers. If your Nova theme scrolls a div with overflow: auto instead of the window, a window.scrollTo call is a no-op. Check the computed scroll container before concluding the package is broken.

Gotchas and Tips

  • Nova version compatibility is the big one. Last release 2020-09-30. Nova 4 and 5 changed asset registration and frontend internals. Before relying on it, verify the script actually loads (DevTools → Network, filter scroll) and that the navigation hook fires on your version. If it doesn't, vendor the five-line version above.
  • Auto-discovery silently off. dont-discover in composer.json, or a stale bootstrap/cache/packages.php, means the provider never registers. php artisan package:discover is your friend.
  • Browser asset cache. Nova serves combined assets; a hard refresh (or incognito) is required to see the effect after install. Don't debug behavior that's still the old bundle.
  • Timing / layout shift. Scrolling to top fires on route change, before async content settles. On slow pages you may see a jump down then back up as the page grows. This package doesn't fix layout shift — loading skeletons with reserved height do that.
  • Back/forward button. Browsers restore scroll position on popstate. Whether the package overrides that depends on the event it hooks; test browser back explicitly, because that's where users notice inconsistency.
  • Duplicate handlers are harmless but pointless. If you already have a nova-navigated handler calling scrollTo, you don't need this package. Conversely, don't install it "just in case" alongside a similar custom asset — you'll spend an hour wondering which one is responsible.
  • Minimal extension points. There is no config file to publish and no middleware. The only extension seam is the JS itself, which means "configure it" really means "fork it". Treat that as a maintenance decision, not a feature.
  • Maintenance risk. MIT-licensed, tiny, unmaintained. It's low-risk code (a scroll call can't break your app), but pin the version in composer.json and note it in your dependency review so it doesn't quietly become a stale transitive dependency at your next Nova upgrade.
  • Debugging checklist: document.querySelector('script[src*="scroll-top"], script[src*="scroll_top"]') in the console → confirm the script is present; set a breakpoint at the top of its handler → confirm it fires on navigation; check document.scrollingElement.scrollTop before/after → distinguish "handler didn't fire" from "handler fired but scrolled the wrong element".
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
diephp/sequences
users-au/socialite-provider
twidpay/twid-logger
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib