diff --git a/js_component.module b/js_component.module
index 4965ebe..bc5a405 100644
--- a/js_component.module
+++ b/js_component.module
@@ -1,5 +1,7 @@
 <?php
 
+use Drupal\Core\Hook\Attribute\LegacyHook;
+use Drupal\js_component\Hook\JsComponentHooks;
 use Drupal\js_component\JSComponentManager;
 use Drupal\js_component\Plugin\Block\JSComponentBlockType;
 use Drupal\js_component\Plugin\JSComponent;
@@ -7,47 +9,19 @@ use Drupal\js_component\Plugin\JSComponent;
 /**
  * Implements hook_library_info_build().
  */
-function js_component_library_info_build() {
-  /** @var JSComponentManager $manager */
-  $manager = \Drupal::service('plugin.manager.js_component');
-
-  $libraries =  [];
-  /** @var JSComponent $instance */
-  foreach ($manager->getDefinitionInstances() as $plugin_id => $instance) {
-    if (!$instance->hasLibraries()) {
-      continue;
-    }
-    $key = "{$instance->provider()}.{$plugin_id}";
-    $libraries[$key] = $instance->processLibraries();
-  }
-
-  return $libraries;
+#[LegacyHook]
+function js_component_library_info_build()
+{
+    return \Drupal::service(JsComponentHooks::class)->libraryInfoBuild();
 }
 
 /**
  * Implements hook_theme().
  */
-function js_component_theme($existing, $type, $theme, $path) {
-  /** @var JSComponentManager $manager */
-  $manager = \Drupal::service('plugin.manager.js_component');
-
-  $theme_info = [];
-  /** @var JSComponent $instance */
-  foreach ($manager->getDefinitionInstances() as $plugin_id => $instance) {
-    if (!$instance->hasTemplate()) {
-      continue;
-    }
-    $theme_info[$instance->componentId()] = [
-      'render element' => 'element',
-      'path' => $instance->getTemplatePath(),
-      'template' => $instance->getTemplateName(),
-      'preprocess functions' => [
-        'template_preprocess_js_component'
-      ]
-    ];
-  }
-
-  return $theme_info;
+#[LegacyHook]
+function js_component_theme($existing, $type, $theme, $path)
+{
+    return \Drupal::service(JsComponentHooks::class)->theme($existing, $type, $theme, $path);
 }
 
 /**
diff --git a/js_component.services.yml b/js_component.services.yml
index 15f37e5..7fc9ceb 100644
--- a/js_component.services.yml
+++ b/js_component.services.yml
@@ -7,3 +7,7 @@ services:
     class: Drupal\js_component\EventSubscriber\JSComponentBuildEventSubscribe
     tags:
       - { name: event_subscriber }
+
+  Drupal\js_component\Hook\JsComponentHooks:
+    class: Drupal\js_component\Hook\JsComponentHooks
+    autowire: true
diff --git a/src/Hook/JsComponentHooks.php b/src/Hook/JsComponentHooks.php
new file mode 100644
index 0000000..2fa256c
--- /dev/null
+++ b/src/Hook/JsComponentHooks.php
@@ -0,0 +1,60 @@
+<?php
+
+namespace Drupal\js_component\Hook;
+
+use Drupal\js_component\JSComponentManager;
+use Drupal\js_component\Plugin\Block\JSComponentBlockType;
+use Drupal\js_component\Plugin\JSComponent;
+use Drupal\Core\Hook\Attribute\Hook;
+/**
+ * Hook implementations for js_component.
+ */
+class JsComponentHooks
+{
+    /**
+     * Implements hook_library_info_build().
+     */
+    #[Hook('library_info_build')]
+    public function libraryInfoBuild()
+    {
+        /** @var JSComponentManager $manager */
+        $manager = \Drupal::service('plugin.manager.js_component');
+        $libraries = [
+        ];
+        /** @var JSComponent $instance */
+        foreach ($manager->getDefinitionInstances() as $plugin_id => $instance) {
+            if (!$instance->hasLibraries()) {
+                continue;
+            }
+            $key = "{$instance->provider()}.{$plugin_id}";
+            $libraries[$key] = $instance->processLibraries();
+        }
+        return $libraries;
+    }
+    /**
+     * Implements hook_theme().
+     */
+    #[Hook('theme')]
+    public function theme($existing, $type, $theme, $path)
+    {
+        /** @var JSComponentManager $manager */
+        $manager = \Drupal::service('plugin.manager.js_component');
+        $theme_info = [
+        ];
+        /** @var JSComponent $instance */
+        foreach ($manager->getDefinitionInstances() as $plugin_id => $instance) {
+            if (!$instance->hasTemplate()) {
+                continue;
+            }
+            $theme_info[$instance->componentId()] = [
+                'render element' => 'element',
+                'path' => $instance->getTemplatePath(),
+                'template' => $instance->getTemplateName(),
+                'preprocess functions' => [
+                    'template_preprocess_js_component',
+                ],
+            ];
+        }
+        return $theme_info;
+    }
+}
