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 Url Field Laravel Package

inspheric/nova-url-field

A URL field for Laravel Nova that displays URLs as clickable, copyable links in index, detail, and form views. Customize link text, target, and styling while storing values as plain strings, keeping long URLs readable and letting users open or copy them with one click.

View on GitHub
Deep Wiki
Context7

Getting Started

  • Match the major to your Nova major before anything else. composer require inspheric/nova-url-field — then pin explicitly: ^3.0 on Nova 5, ^2.0.2 on Nova 4. The package major is the Nova major. Do not float ("inspheric/nova-url-field": "*") and do not assume v3.0 is a drop-in upgrade from v2.x; the release notes only say Nova 5 support was added and say nothing about what was dropped or whether the PHP floor moved. Diff the composer.json between the two tags before committing.
  • There is nothing else to install. No service provider registration, no config/ publish, no migrations, no compiled assets, no nova:publish step. The whole package is a field class plus its Vue component. "Installed" means the composer require succeeded.
  • The one place to look is your resource's fields() method. That is the entire integration surface. Import Inspheric\NovaUrlField\Url and swap whatever Text::make('Website') you already have.
  • Prerequisites: Laravel + Laravel Nova (commercial license) + Composer. Nova being closed-source matters later — your CI needs license credentials in composer.json's http-basic/nova config or composer install dies before a single test runs.
  • First use case: a website / homepage / docs_url column on a resource admins actually browse. You get a plain text input on create/edit, and a clickable anchor on index and detail, for free.
use Inspheric\NovaUrlField\Url;

public function fields(NovaRequest $request)
{
    return [
        Url::make('Website')
            ->rules('url', 'max:255')
            ->nullable(),
    ];
}

First milestone: open the index, click the link, open the detail view, click the link, then edit the record, blank the field, save, and reload. That last step is the one that regresses across majors — verify it explicitly on your Nova version before converting a second resource.

Implementation Patterns

  • Replace the display hack, not the column. If you currently have Text::make('Website')->displayUsing(fn ($v) => "<a href=\"{$v}\">…</a>") (or worse, ->asHtml()), this package is the clean swap. Same database column, same stored value, zero migration. Rollback is a one-line revert per field, which is what makes opportunism safe here.
  • Normalize the scheme at the model, not the field. Laravel's url rule rejects example.com (no scheme). Rather than teaching admins to type https://, add a small mutator or Attribute cast that prepends https:// when no scheme is present. Then ->rules('url') passes, the anchor href is valid, and sorting is at least consistent.
protected function website(): Attribute
{
    return Attribute::make(
        set: fn (?string $value) => $value && ! str_contains($value, '://')
            ? 'https://'.$value
            : $value,
    );
}
  • Validation is still yours. The package renders; it does not police input. Stack ->rules('url', 'max:255'), ->nullable(), and a starts_with:http,https if the column accepts untrusted input. Avoid active_url — it does a DNS lookup on every save.
  • Nullability must be set on both sides. ->nullable() on the field and a nullable column. Without it, an empty submit stores '', and an <a href=""> renders as a link back to the current admin page. This is the single most common "the field is broken" report.
  • Shape the surfaces with Nova's standard methods. ->onlyOnDetail() for long URLs with query strings that wreck the index table, ->hideFromIndex() for callback/webhook endpoints nobody needs to click from a list, ->sortable() only when the ordering is actually meaningful (see Gotchas).
  • Gate visibility with ->canSee(), not conditional markup. Published-only links, admin-only vendor portals, per-tenant links — resolve them in the resource or in canSee(). Don't try to build markup inside the field.
  • Link text and target behavior are configurable on the field per the package docs — use them to show a friendly label ("Vendor portal") instead of a 200-character URL, and to open external references in a new tab. Confirm the exact method names against the installed version's source before copy-pasting from a blog post; the API is small and the README is the source of truth.
  • Pair it with Nova natives. ->copyable() is genuinely useful on endpoint/webhook URL columns. ->help() for format hints. ->textAlign('left') so the index column doesn't inherit Nova's default alignment and look misaligned next to text fields.
  • Where this earns its keep day-to-day: vendor/partner portals, documentation shortcuts, repo and ticket links, webhook and callback endpoints, affiliate URLs, internal link directories. Convert opportunistically as you touch each resource — do not schedule a "convert all Text fields to Url fields" refactor for a dependency this small.
  • Stage the rollout. One non-critical resource in staging, one release behind a flag if you have that machinery. Validate: index render, detail render, null round-trip, edit round-trip, canSee behavior. Then generalize.
  • Testing: assertions go through Nova's own field test helpers (assertSee, Nova::assertFields) rather than HTTP-level DOM scraping. If you write a feature test that hits the detail screen, assert on the href attribute, not on "the page contains the URL" — the raw string appears in the form field too.

Gotchas and Tips

  • The major version is the Nova version, and the upgrade path is undocumented. v3.x = Nova 5, v2.x = Nova 4. On Nova 4, composer update simply won't take v3.0 — and forcing it breaks the field. Annotate your internal dependency allowlist with "Nova 5+ only." Read the composer.json diff between v2.0.2 and v3.0 to find the real dropped-version and PHP constraints; the release notes are an information gap, not a specification.
  • URL schemes are a security review item, not hygiene. If the column accepts user input, javascript: and data: payloads can survive any rule that only checks URL shape. Add starts_with:http,https or an explicit allowlist, and confirm target="_blank" anchors carry rel="noopener noreferrer". The v3.0 notes make no claim either way — assume nothing and check the rendered markup yourself.
  • Check the column width before blaming the field. VARCHAR(255) is the usual culprit when long query-string URLs truncate silently (or throw in strict SQL mode). It looks like a rendering bug and isn't.
  • '' vs null — again, because it's the #1 false alarm. Empty string → anchor to the current page → "your package is broken."
  • Sorting is lexicographic on the raw string. https://a.com and www.a.com sort miles apart and domains are ignored entirely. Don't expose ->sortable() on a link column if admins expect domain grouping — or normalize schemes first, which at least removes the worst of it.
  • Don't layer ->displayUsing() on top of it. The field's whole value is the anchor it renders. If you replace the display, you're back to hand-rolled markup and you've lost the reason you added the dependency.
  • It is display sugar — don't grow it. No favicons, previews, metadata extraction, redirects, or click tracking. If those appear in the requirements, that's a custom field or a separate service, not a config flag.
  • Debugging order when a link doesn't render: (1) dd() / tinker the raw database value — is it null, '', or a schemeless string? (2) check the field isn't hidden by canSee or an onlyOn* method; (3) view-source the rendered anchor in the browser to see what href actually got emitted; (4) confirm the installed major matches your Nova major via composer show inspheric/nova-url-field. Nova caches nothing exotic here, so a stale-component problem is rare — the stored value and the visibility rules are almost always it.
  • The extension point is your own subclass. If you need scheme sanitizing, custom anchor markup, or rel enforcement baked in, subclass Inspheric\NovaUrlField\Url and override resolve/meta. Document that path in your team wiki: it turns an upstream stall or a future Nova-major break into a two-hour task instead of a rewrite.
  • Bus factor of one. ~102 stars, 0 dependents, single primary maintainer (the Nova 5 PR came from an outside contributor, which is an encouraging signal but is one release, not a track record). Keep it strictly in admin tooling — never in a request path that serves end users. Commit the lockfile, vendor or fork the class if it becomes load-bearing, and note that the fallback is trivial: Nova's native Text field or a fifty-line custom field. That cheap exit is the main reason this dependency is safe to adopt.
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.
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator