diff --git a/debug_bar.module b/debug_bar.module
index a6d9f18..8160a3e 100644
--- a/debug_bar.module
+++ b/debug_bar.module
@@ -1,12 +1,17 @@
 <?php
 
+/**
+ * @file
+ */
+
 declare(strict_types=1);
 
 /**
  * @file
  * Primary module hooks for debug_bar module.
  */
-
+use Drupal\Core\Hook\Attribute\LegacyHook;
+use Drupal\debug_bar\Hook\DebugBarHooks;
 use Drupal\debug_bar\Data\DebugBarItem;
 
 /**
@@ -14,10 +19,9 @@ use Drupal\debug_bar\Data\DebugBarItem;
  *
  * @phpstan-param array{'#attached': array{'#attached': array{'library': list<non-empty-string>}}} &$page
  */
+#[LegacyHook]
 function debug_bar_page_attachments(array &$page): void {
-  if (\Drupal::currentUser()->hasPermission('view debug bar')) {
-    $page['#attached']['library'][] = 'debug_bar/debug_bar';
-  }
+  \Drupal::service(DebugBarHooks::class)->pageAttachments($page);
 }
 
 /**
@@ -25,15 +29,9 @@ function debug_bar_page_attachments(array &$page): void {
  *
  * @phpstan-ignore-next-line
  */
+#[LegacyHook]
 function debug_bar_theme(): array {
-  return [
-    'debug_bar' => [
-      'variables' => [
-        'items' => [],
-        'attributes' => [],
-      ],
-    ],
-  ];
+  return \Drupal::service(DebugBarHooks::class)->theme();
 }
 
 /**
diff --git a/debug_bar.services.yml b/debug_bar.services.yml
index 84aa1fe..c992823 100644
--- a/debug_bar.services.yml
+++ b/debug_bar.services.yml
@@ -25,3 +25,7 @@ services:
       - '@renderer'
       - '@datetime.time'
       - '@extension.list.module'
+
+  Drupal\debug_bar\Hook\DebugBarHooks:
+    class: Drupal\debug_bar\Hook\DebugBarHooks
+    autowire: true
diff --git a/src/Hook/DebugBarHooks.php b/src/Hook/DebugBarHooks.php
new file mode 100644
index 0000000..15437a0
--- /dev/null
+++ b/src/Hook/DebugBarHooks.php
@@ -0,0 +1,41 @@
+<?php
+
+namespace Drupal\debug_bar\Hook;
+
+use Drupal\Core\Hook\Attribute\Hook;
+
+/**
+ * Hook implementations for debug_bar.
+ */
+class DebugBarHooks {
+
+  /**
+   * Implements hook_attachments().
+   *
+   * @phpstan-param array{'#attached': array{'#attached': array{'library': list<non-empty-string>}}} &$page
+   */
+  #[Hook('attachments', module: 'debug_bar_page')]
+  public static function pageAttachments(array &$page): void {
+    if (\Drupal::currentUser()->hasPermission('view debug bar')) {
+      $page['#attached']['library'][] = 'debug_bar/debug_bar';
+    }
+  }
+
+  /**
+   * Implements hook_theme().
+   *
+   * @phpstan-ignore-next-line
+   */
+  #[Hook('theme')]
+  public static function theme(): array {
+    return [
+      'debug_bar' => [
+        'variables' => [
+          'items' => [],
+          'attributes' => [],
+        ],
+      ],
+    ];
+  }
+
+}
