Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

madprabh's avatar

Alpine js works with inertia+vue stack?

Hey Folks,

Has anyone tried using Alpine js with inertia and vue stack. I have a project which is based on Jetstream (inertia+vue stack). I am thinking of using Penguinui library and that uses Apline. But I am unsure if that would cause any conflicts with vue js.

0 likes
1 reply
LaryAI's avatar
Level 58

Yes, you can use Alpine.js alongside an Inertia.js + Vue.js stack. They can coexist without conflicts, as they operate in different scopes. Alpine.js is a lightweight JavaScript framework that enhances HTML with declarative behavior, while Vue.js is a more comprehensive framework for building user interfaces.

Here are some tips to ensure smooth integration:

  1. Scope Separation: Alpine.js and Vue.js can be used together as long as you keep their scopes separate. Alpine.js is great for handling simple interactions and can be used in parts of your application where you don't need the full power of Vue.js.

  2. Avoid Overlapping: Make sure that the elements controlled by Alpine.js do not overlap with those controlled by Vue.js. This will prevent any potential conflicts.

  3. Loading Order: Ensure that Alpine.js is loaded after Vue.js. This is important because Vue.js might take over the DOM elements if it is loaded after Alpine.js.

  4. Use Cases: Use Alpine.js for simple UI interactions and enhancements, and reserve Vue.js for more complex state management and component-based architecture.

Here's a basic example of how you might structure your HTML to use both frameworks:

<!-- Vue.js component -->
<div id="app">
  <example-component></example-component>
</div>

<!-- Alpine.js component -->
<div x-data="{ open: false }">
  <button @click="open = !open">Toggle</button>
  <div x-show="open">
    This is an Alpine.js controlled element.
  </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
<script src="https://cdn.jsdelivr.net/npm/alpinejs@3" defer></script>
<script>
  new Vue({
    el: '#app',
    components: {
      'example-component': {
        template: '<div>This is a Vue.js component.</div>'
      }
    }
  });
</script>

In this example, the Vue.js component and the Alpine.js component are separate, ensuring that they do not interfere with each other. This approach allows you to leverage the strengths of both frameworks in your project.

Please or to participate in this conversation.