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

martinszeltins's avatar

Vue - What is the difference between Composition API and simple imports?

Vue 3.0 is out! Yay! As far as I understand, the Composition API allows for code reuse, right?

So what advantage does the Composition API have over a simple imported class that is shared across components?

Can’t I simply do this if I want to reuse code? Why do I need composition api?

import Shared from './shared.js'

class Shared {
  sharedFunction()
  {
  }
}

export default Shared
0 likes
2 replies

Please or to participate in this conversation.