Send a Pennant flag to a Vue page

Feature::for($user)->active() becomes a boolean prop. The controller checks the same flag before it writes.

For your AI agent

Copies a prompt. Paste it into the AI agent you already have open.

Read https://laravel-vuejs.space/laravel-pennant-feature-flag-vue.md
Feature::for($user)->active() becomes a boolean prop. The controller checks the same flag before it writes.
Do not send the flag list to the browser and trust a posted newEditor: true.
Do not call the provider from the page to "evaluate the flag".
Show the diff. Do not commit.
On this page · 2 sections
  1. The fix
  2. FAQ

People searching “Laravel Pennant Vue” hide a button and let the POST through. A flag is a server check that you also copy into a prop. The stack guide is the app this flag sits on.

TL;DR

  • Feature::for($user)->active() becomes a boolean prop.
  • The controller checks the same flag before it writes.
  • Do not send the flag list to the browser and trust a posted newEditor: true.
  • Do not call the provider from the page to “evaluate the flag”.

Who it's for: Laravel + Vue developers

Applies to: Laravel 13 · Vue 3

The fix#

shell
composer require laravel/pennant
php
use Laravel\Pennant\Feature;

Feature::define('new-editor', function (User $user) {
    return (bool) $user->is_admin;
});

Define that in a service provider, not in the Vue page.

php
$enabled = $request->user()
    ? Feature::for($request->user())->active('new-editor')
    : false;

return Inertia::render('posts/Edit', [
    'newEditor' => $enabled,
]);
vue
<section v-if="newEditor">New editor</section>

The store method checks active('new-editor') again before it writes. Do not send the flag list to the browser and trust a posted newEditor: true. Do not call the provider from the page to “evaluate the flag”.

FAQ#

How do I send a Pennant flag to a Vue page?

Feature::for($user)->active() becomes a boolean prop. The controller checks the same flag before it writes.

What goes wrong with Laravel Pennant Vue?

Many developers hide a button and let the POST through. Do not send the flag list to the browser and trust a posted newEditor: true.

Found this useful?

Ask questions, share what you built.

Join thousands of Laravel and Vue developers in our Facebook group, or get new posts in your Telegram feed. Sharing this article helps too.

Keep reading

Newsletter

Get the best of Laravel & Vue, once a month.

One short email with new guides, release notes worth reading and hand-picked community links. No spam, unsubscribe any time.