---
title: Composing use Hooks | Tutorial
contributors:
  - adamdbradley
  - manucorporat
  - mrhoodz
updated_at: '2023-06-25T19:43:33Z'
created_at: '2022-08-02T12:07:45Z'
---

Hooks are a way to abstract common logic away from the components that use it. They are a way to share logic between components. While Qwik provides many hooks, there will always be one that is not provided out of the box. This tutorial will show you how to create your own hook.

In this example, the registering of `mousemove` events is something that could be shared between multiple components. Refactor the code by pulling out the code before JSX into its own `useMousePosition()` function.

Congratulations, you have successfully created your own hook! You can now use it in any component that needs to listen to the mouse position.
