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

ufodisko's avatar

Options API alongside Composition API?

Just wondering if it's ok to use Options API alongside Composition API

I'm a big fan of Options API and have never used Composition API before.

I just installed Jetstream (with Inertia/Vue) and it comes with Composition API by default.

However, I used Options API (as a test) in of the components and it looks like it's working.

<script setup>
import AppLayout from "@/Layouts/AppLayout.vue"
</script>

<script>
import { Head, Link } from '@inertiajs/vue3';
import { defineComponent } from "vue"

export default defineComponent({
    // I directly send properties from backend and they get populated in as props
    props: {
        title: String,
        content: String
    },
    methods: {
        alert() {
            alert('This button works')
        }
    }
});
</script>

<template>
    <Head title="Test" />

    <AppLayout title="Test">
        <template #header>
            <h2 class="font-semibold text-xl text-gray-800 leading-tight">
                Test
            </h2>
        </template>

        <div class="py-12">
            <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
                <div class="bg-white overflow-hidden shadow-xl sm:rounded-lg p-5">
                    <button class="p-2 bg-purple-500 hover:bg-purple-700 text-white rounded" @click="alert">Click Me</button>
                </div>
            </div>
        </div>
    </AppLayout>
</template>
0 likes
3 replies
martinbean's avatar

Just wondering if it's ok to use Options API alongside Composition API

@ufodisko No. It’s one or the other.

ufodisko's avatar

@martinbean What are the drawbacks of keeping Composition API for Jetstream but Options API for the rest of the app?

Please or to participate in this conversation.