Is it a convention to start filename with 'use' when naming Vue 3 js modules?

Viewed 1459

I've started using the new Vue 3 for months, there seems to be no style guide for new Vue 3 since the official release in September. So far I just see the most comprehensive documentation here:

Vue Composition api

I find that the example js module names usually have the prefix "use" in the documentation and in some online tutorials. Foe example, useMousePosition.js. I just wonder if it's a convention and is there any meaning behind the prefix "use"?

And one more question, I keep most "non-UI" logics in the js files, and UI-related data and methods in vue files. This was also my approach when doing in the old Vue 2. Is this a proper way also when working in Vue3 ?

Thank you!

1 Answers

The Composition API RFC covers this in this section.

Excerpt

Notice how all the logic related to the create new folder feature is now collocated and encapsulated in a single function. The function is also somewhat self-documenting due to its descriptive name. This is what we call a composition function. It is a recommended convention to start the function's name with use to indicate that it is a composition function. This pattern can be applied to all the other logical concerns in the component

Related