diff --git a/composer.json b/composer.json
index 8497559..f528018 100644
--- a/composer.json
+++ b/composer.json
@@ -17,7 +17,7 @@
     },
     "require": {
         "php": ">=8.1",
-        "drupal/core": "^10.3 || ^11",
-        "drupal/webform": "^6.3"
+        "drupal/webform": "^6.3",
+        "drupal/core": "^10.3 || ^11 || ^12"
     }
 }
diff --git a/src/Hook/WebformSubmitTimerHooks.php b/src/Hook/WebformSubmitTimerHooks.php
new file mode 100644
index 0000000..e5466b5
--- /dev/null
+++ b/src/Hook/WebformSubmitTimerHooks.php
@@ -0,0 +1,60 @@
+<?php
+
+namespace Drupal\webform_submit_timer\Hook;
+
+use Drupal\webform\Entity\Webform;
+use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Hook\Attribute\Hook;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
+
+/**
+ * Hook implementations for webform_submit_timer.
+ */
+class WebformSubmitTimerHooks {
+  use StringTranslationTrait;
+
+  /**
+   * Implements hook_form_alter().
+   */
+  #[Hook('form_alter')]
+  public function formAlter(array &$form, FormStateInterface $form_state, string $form_id): void {
+    if (!str_starts_with($form_id, 'webform_submission')) {
+      return;
+    }
+    $form_object = $form_state->getFormObject();
+    if (!method_exists($form_object, 'getWebform')) {
+      return;
+    }
+    // Get the Webform entity.
+    $webform = $form_object->getWebform();
+    if (!$webform instanceof Webform) {
+      return;
+    }
+    // Load the timer from configuration.
+    $config = \Drupal::config('webform_submit_timer.settings');
+    $timer = (int) $config->get('timers.' . $webform->id());
+    if ($timer < 1) {
+      return;
+    }
+    $form_id_html = $form['#id'] ?? $webform->id();
+    $form['#attached']['library'][] = 'webform_submit_timer/submit_timer';
+    $form['#attached']['drupalSettings']['webformSubmitTimer'][$form_id_html] = [
+      'timer' => $timer,
+    ];
+    // Add countdown message.
+    $form['submit_timer_message'] = [
+      '#type' => 'html_tag',
+      '#tag' => 'div',
+      '#attributes' => [
+        'class' => [
+          'webform-submit-timer-message',
+        ],
+      ],
+      '#value' => $this->t('Please wait <strong><span class="webform-timer-count">@timer</span> seconds</strong> before submitting.', [
+        '@timer' => $timer,
+      ]),
+      '#weight' => 10,
+    ];
+  }
+
+}
diff --git a/webform_submit_timer.info.yml b/webform_submit_timer.info.yml
index ce8d37b..51be091 100644
--- a/webform_submit_timer.info.yml
+++ b/webform_submit_timer.info.yml
@@ -1,7 +1,7 @@
 name: Webform Submit Timer
 type: module
 description: Adds a submit delay timer to Webforms.
-core_version_requirement: ^10.3 || ^11
+core_version_requirement: ^10.3 || ^11 || ^12
 package: Webform
 dependencies:
   - webform:webform
diff --git a/webform_submit_timer.module b/webform_submit_timer.module
index 356614f..bea8858 100644
--- a/webform_submit_timer.module
+++ b/webform_submit_timer.module
@@ -7,51 +7,14 @@
 
 declare(strict_types=1);
 
+use Drupal\Core\Hook\Attribute\LegacyHook;
+use Drupal\webform_submit_timer\Hook\WebformSubmitTimerHooks;
 use Drupal\Core\Form\FormStateInterface;
-use Drupal\webform\Entity\Webform;
 
 /**
  * Implements hook_form_alter().
  */
+#[LegacyHook]
 function webform_submit_timer_form_alter(array &$form, FormStateInterface $form_state, string $form_id): void {
-  if (!str_starts_with($form_id, 'webform_submission')) {
-    return;
-  }
-
-  $form_object = $form_state->getFormObject();
-  if (!method_exists($form_object, 'getWebform')) {
-    return;
-  }
-
-  // Get the Webform entity.
-  $webform = $form_object->getWebform();
-  if (!$webform instanceof Webform) {
-    return;
-  }
-
-  // Load the timer from configuration.
-  $config = \Drupal::config('webform_submit_timer.settings');
-  $timer = (int) $config->get('timers.' . $webform->id());
-  if ($timer < 1) {
-    return;
-  }
-
-  $form_id_html = $form['#id'] ?? $webform->id();
-
-  $form['#attached']['library'][] = 'webform_submit_timer/submit_timer';
-  $form['#attached']['drupalSettings']['webformSubmitTimer'][$form_id_html] = [
-    'timer' => $timer,
-  ];
-
-  // Add countdown message.
-  $form['submit_timer_message'] = [
-    '#type' => 'html_tag',
-    '#tag' => 'div',
-    '#attributes' => ['class' => ['webform-submit-timer-message']],
-    '#value' => t(
-      'Please wait <strong><span class="webform-timer-count">@timer</span> seconds</strong> before submitting.',
-      ['@timer' => $timer],
-    ),
-    '#weight' => 10,
-  ];
+  \Drupal::service(WebformSubmitTimerHooks::class)->formAlter($form, $form_state, $form_id);
 }
diff --git a/webform_submit_timer.services.yml b/webform_submit_timer.services.yml
new file mode 100644
index 0000000..25bc2e8
--- /dev/null
+++ b/webform_submit_timer.services.yml
@@ -0,0 +1,5 @@
+
+services:
+  Drupal\webform_submit_timer\Hook\WebformSubmitTimerHooks:
+    class: Drupal\webform_submit_timer\Hook\WebformSubmitTimerHooks
+    autowire: true
