invato/redirect-to-index
Laravel package that provides a simple way to redirect requests to your application's index page or route. Configure the target and middleware, then enforce a canonical entry point or handle fallback redirects with minimal setup. Lightweight and Composer-ready.
invato/redirect-to-index is a micro-package whose entire job is to change Nova's post-create / post-update redirect target from the resource's detail page to its index (list) page. It is a trait you opt into per resource.
composer require invato/redirect-to-index
app/Nova/User.php, and add the trait:
use Invato\RedirectToIndex\RedirectsToIndex;
class User extends Resource
{
use RedirectsToIndex;
}
User in the Nova UI. Instead of landing on /resources/users/42, you land on /resources/users.Look first at the package's src/ — you'll find a single trait overriding redirectAfterCreate() and redirectAfterUpdate() (the static methods on Laravel\Nova\Resource that return the redirect path). That is the whole surface area; there is no config, service provider behavior, or middleware to reason about.
First use case: rapid data-entry workflows (invoices, inventory, log entries) where an operator is creating many records in a row and the detail screen is dead weight between entries.
Per-resource opt-in. The trait is designed to be sprinkled only where it helps. Apply it to high-volume CRUD resources and leave resources where the detail view is the natural next step (profiles, orders you immediately inspect) on Nova's default behavior.
Base resource class. The cleaner day-to-day pattern is a project-level App\Nova\Resource that extends Laravel\Nova\Resource, applies the trait once, and have every generated resource extend that. You get consistent index-redirect behavior project-wide without remembering to add a use line to each new nova:resource.
Mix with other redirect customizations. If you already override redirectAfterCreate/redirectAfterUpdate for conditional routing (e.g. redirect to a related resource), the trait will conflict — PHP will fatal on the duplicate method. Pick one: either the trait for the simple case, or hand-written overrides for the conditional case.
Pair with index filters. Redirecting to index is most useful when the index is pre-filtered to the record you just created (e.g. a CreatedBy filter or a default sort on created_at desc). Combine the trait with $filters / $defaultSort on the resource so the user sees their new record at the top of the index rather than hunting for it.
Inline actions. This trait only affects the standard create/update form submits. It does not touch Action redirects, Lens navigation, or inline-creation modals — those have their own response handling. If your workflow uses inline create, test it separately.
redirectAfterCreate(NovaRequest $request, $resource) / redirectAfterUpdate(...) with specific signatures. Nova has changed these across major versions. If a Nova upgrade breaks redirects, this trait is the first place to look — a signature mismatch means the method is silently ignored (no error, just the old behavior back).redirectAfterCreate in the resource (method on the class wins over the trait), and (c) no parent class also defines it. Use dd(static::redirectAfterCreate(...)) from a tinker-style test to confirm the path returned.uriKey or missing the /resources/ prefix.Nova::actingAs() and assert a redirect to /nova/resources/{uriKey}. Worth adding if you keep the dependency, because the failure mode above is silent.How can I help you explore Laravel packages today?