diff --git a/src/Bootstrap.php b/src/Bootstrap.php
index 4bb1821..026d14c 100644
--- a/src/Bootstrap.php
+++ b/src/Bootstrap.php
@@ -1244,6 +1244,10 @@ class Bootstrap {
   public static function isAdmin(UserInterface $user = NULL) {
     static $admins = [];
     $user = $user ?: User::load(\Drupal::currentUser()->id());
+    // currentUser() can be anonymous and therefore User::load() can return null in that case
+    if (!$user) {
+      return FALSE;
+    }
     $uid = (int) $user->id();
     if (!isset($admins[$uid])) {
       $admins[$uid] = $user->hasPermission('access administration pages');
