diff --git a/composer.json b/composer.json
index 9db9f31..f577991 100644
--- a/composer.json
+++ b/composer.json
@@ -10,6 +10,6 @@
         "source": "https://git.drupalcode.org/project/jserror"
     },
     "require": {
-        "drupal/core": "^11"
+        "drupal/core": "^11.0 || ^12"
     }
 }
diff --git a/jserror.info.yml b/jserror.info.yml
index 368f404..d4ce6e3 100644
--- a/jserror.info.yml
+++ b/jserror.info.yml
@@ -2,5 +2,5 @@ name: JSerror
 type: module
 description: 'Logs client-side JavaScript errors from real users into the Drupal database, with sampling and flood control for production use.'
 package: Development
-core_version_requirement: ^11
+core_version_requirement: ^11.0 || ^12
 configure: jserror.settings
diff --git a/jserror.module b/jserror.module
index 8fc42e8..ad2ed2d 100644
--- a/jserror.module
+++ b/jserror.module
@@ -7,37 +7,18 @@
 
 declare(strict_types=1);
 
+use Drupal\Core\Hook\Attribute\LegacyHook;
+use Drupal\jserror\Hook\JserrorHooks;
 use Drupal\Component\Render\MarkupInterface;
 use Drupal\Core\Render\Markup;
 use Drupal\Core\Routing\RouteMatchInterface;
-use Drupal\Core\Url;
 
 /**
  * Implements hook_help().
  */
+#[LegacyHook]
 function jserror_help(string $route_name, RouteMatchInterface $route_match): string {
-  switch ($route_name) {
-    case 'help.page.jserror':
-      $output = '<h3>' . t('About') . '</h3>';
-      $output .= '<p>' . t("JSerror records JavaScript errors that occur in visitors' browsers and stores them in the Drupal database, so that breakage only reproducible on a particular browser, device or locale becomes visible to site maintainers.") . '</p>';
-      $output .= '<h3>' . t('Uses') . '</h3>';
-      $output .= '<dl>';
-      $output .= '<dt>' . t('Reviewing reported errors') . '</dt>';
-      $output .= '<dd>' . t('Errors are listed on the <a href=":report">Recent JavaScript errors</a> page, grouped by message so that a single fault does not fill the report. Each entry can be opened to see the individual occurrences, along with the pages, browsers and platforms affected.', [
-        ':report' => Url::fromRoute('jserror.reports')->toString(),
-      ]) . '</dd>';
-      $output .= '<dt>' . t('Running on a production site') . '</dt>';
-      $output .= '<dd>' . t('Reporting can be limited to a percentage of visitors, capped per page and per client per hour, and old records trimmed on cron. These are configured on the <a href=":settings">JSerror settings</a> page.', [
-        ':settings' => Url::fromRoute('jserror.settings')->toString(),
-      ]) . '</dd>';
-      $output .= '</dl>';
-      return $output;
-
-    case 'jserror.reports':
-      return '<p>' . t("JavaScript errors captured in visitors' browsers, grouped by message. The most frequently reported errors appear first.") . '</p>';
-  }
-
-  return '';
+  return \Drupal::service(JserrorHooks::class)->help($route_name, $route_match);
 }
 
 /**
@@ -48,38 +29,9 @@ function jserror_help(string $route_name, RouteMatchInterface $route_match): str
  * loading are caught. Errors are buffered and the reporter is fetched on the
  * load event, so capture never delays rendering.
  */
+#[LegacyHook]
 function jserror_page_attachments(array &$attachments): void {
-  $config = \Drupal::config('jserror.settings');
-
-  // The settings are baked into the markup, so the page must be rebuilt when
-  // they change.
-  $attachments['#cache']['tags'][] = 'config:jserror.settings';
-
-  $module_path = \Drupal::service('extension.list.module')->getPath('jserror');
-
-  $settings = [
-    // Percentage of visitors to sample.
-    'p' => (int) $config->get('percentage'),
-    // Whether to swallow the error so it never reaches the browser console.
-    's' => $config->get('suppress_warning') ? 1 : 0,
-    // Where the reporter script lives.
-    'u' => base_path() . $module_path . '/js/jserror.js',
-    // Where reports are POSTed.
-    'e' => Url::fromRoute('jserror.log')->toString(),
-    // How many reports this page may send.
-    'l' => (int) $config->get('page_limit'),
-    // Whether the reporter should narrate what it is doing to the console.
-    'd' => $config->get('debug_mode') ? 1 : 0,
-  ];
-
-  $attachments['#attached']['html_head'][] = [
-    [
-      '#tag' => 'script',
-      '#value' => _jserror_bootstrap_script($settings),
-      '#weight' => -1000,
-    ],
-    'jserror_bootstrap',
-  ];
+  \Drupal::service(JserrorHooks::class)->pageAttachments($attachments);
 }
 
 /**
@@ -141,21 +93,15 @@ function _jserror_bootstrap_script(array $settings): MarkupInterface {
 /**
  * Implements hook_theme().
  */
+#[LegacyHook]
 function jserror_theme(): array {
-  return [
-    'jserror_list' => [
-      'variables' => ['errors' => [], 'empty' => NULL],
-    ],
-    'jserror_detail' => [
-      'variables' => ['error' => [], 'occurrences' => [], 'empty' => NULL],
-    ],
-  ];
+  return \Drupal::service(JserrorHooks::class)->theme();
 }
 
 /**
  * Implements hook_cron().
  */
+#[LegacyHook]
 function jserror_cron(): void {
-  $row_limit = (int) \Drupal::config('jserror.settings')->get('row_limit');
-  \Drupal::service('jserror.storage')->prune($row_limit);
+  \Drupal::service(JserrorHooks::class)->cron();
 }
diff --git a/jserror.services.yml b/jserror.services.yml
index c7e05e2..de6b609 100644
--- a/jserror.services.yml
+++ b/jserror.services.yml
@@ -8,3 +8,7 @@ services:
 
   Drupal\jserror\UserAgentParser: '@jserror.user_agent'
   Drupal\jserror\JserrorStorage: '@jserror.storage'
+
+  Drupal\jserror\Hook\JserrorHooks:
+    class: Drupal\jserror\Hook\JserrorHooks
+    autowire: true
diff --git a/src/Hook/JserrorHooks.php b/src/Hook/JserrorHooks.php
new file mode 100644
index 0000000..e2f264f
--- /dev/null
+++ b/src/Hook/JserrorHooks.php
@@ -0,0 +1,117 @@
+<?php
+
+namespace Drupal\jserror\Hook;
+
+use Drupal\Component\Render\MarkupInterface;
+use Drupal\Core\Render\Markup;
+use Drupal\Core\Routing\RouteMatchInterface;
+use Drupal\Core\Url;
+use Drupal\Core\Hook\Attribute\Hook;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
+/**
+ * Hook implementations for jserror.
+ */
+class JserrorHooks
+{
+    use StringTranslationTrait;
+    /**
+     * Implements hook_help().
+     */
+    #[Hook('help')]
+    public function help(string $route_name, \Drupal\Core\Routing\RouteMatchInterface $route_match): string
+    {
+        switch ($route_name) {
+            case 'help.page.jserror':
+                $output = '<h3>' . $this->t('About') . '</h3>';
+                $output .= '<p>' . $this->t("JSerror records JavaScript errors that occur in visitors' browsers and stores them in the Drupal database, so that breakage only reproducible on a particular browser, device or locale becomes visible to site maintainers.") . '</p>';
+                $output .= '<h3>' . $this->t('Uses') . '</h3>';
+                $output .= '<dl>';
+                $output .= '<dt>' . $this->t('Reviewing reported errors') . '</dt>';
+                $output .= '<dd>' . $this->t('Errors are listed on the <a href=":report">Recent JavaScript errors</a> page, grouped by message so that a single fault does not fill the report. Each entry can be opened to see the individual occurrences, along with the pages, browsers and platforms affected.', [
+                    ':report' => \Drupal\Core\Url::fromRoute('jserror.reports')->toString(),
+                ]) . '</dd>';
+                $output .= '<dt>' . $this->t('Running on a production site') . '</dt>';
+                $output .= '<dd>' . $this->t('Reporting can be limited to a percentage of visitors, capped per page and per client per hour, and old records trimmed on cron. These are configured on the <a href=":settings">JSerror settings</a> page.', [
+                    ':settings' => \Drupal\Core\Url::fromRoute('jserror.settings')->toString(),
+                ]) . '</dd>';
+                $output .= '</dl>';
+                return $output;
+            case 'jserror.reports':
+                return '<p>' . $this->t("JavaScript errors captured in visitors' browsers, grouped by message. The most frequently reported errors appear first.") . '</p>';
+        }
+        return '';
+    }
+    /**
+     * Implements hook_page_attachments().
+     *
+     * Places the bootstrap script in the document head, ahead of every other
+     * script, so that errors thrown while the site's own JavaScript is still
+     * loading are caught. Errors are buffered and the reporter is fetched on the
+     * load event, so capture never delays rendering.
+     */
+    #[Hook('page_attachments')]
+    public function pageAttachments(array &$attachments): void
+    {
+        $config = \Drupal::config('jserror.settings');
+        // The settings are baked into the markup, so the page must be rebuilt when
+        // they change.
+        $attachments['#cache']['tags'][] = 'config:jserror.settings';
+        $module_path = \Drupal::service('extension.list.module')->getPath('jserror');
+        $settings = [
+            // Percentage of visitors to sample.
+            'p' => (int) $config->get('percentage'),
+            // Whether to swallow the error so it never reaches the browser console.
+            's' => $config->get('suppress_warning') ? 1 : 0,
+            // Where the reporter script lives.
+            'u' => base_path() . $module_path . '/js/jserror.js',
+            // Where reports are POSTed.
+            'e' => \Drupal\Core\Url::fromRoute('jserror.log')->toString(),
+            // How many reports this page may send.
+            'l' => (int) $config->get('page_limit'),
+            // Whether the reporter should narrate what it is doing to the console.
+            'd' => $config->get('debug_mode') ? 1 : 0,
+        ];
+        $attachments['#attached']['html_head'][] = [
+            [
+                '#tag' => 'script',
+                '#value' => _jserror_bootstrap_script($settings),
+                '#weight' => -1000,
+            ],
+            'jserror_bootstrap',
+        ];
+    }
+    /**
+     * Implements hook_theme().
+     */
+    #[Hook('theme')]
+    public function theme(): array
+    {
+        return [
+            'jserror_list' => [
+                'variables' => [
+                    'errors' => [
+                    ],
+                    'empty' => NULL,
+                ],
+            ],
+            'jserror_detail' => [
+                'variables' => [
+                    'error' => [
+                    ],
+                    'occurrences' => [
+                    ],
+                    'empty' => NULL,
+                ],
+            ],
+        ];
+    }
+    /**
+     * Implements hook_cron().
+     */
+    #[Hook('cron')]
+    public function cron(): void
+    {
+        $row_limit = (int) \Drupal::config('jserror.settings')->get('row_limit');
+        \Drupal::service('jserror.storage')->prune($row_limit);
+    }
+}
