diff --git a/cgi.cabal b/cgi.cabal
--- a/cgi.cabal
+++ b/cgi.cabal
@@ -1,5 +1,5 @@
 name:               cgi
-version:            3001.5.0.1
+version:            3001.5.1.0
 synopsis:           A library for writing CGI programs
 description:        This is a Haskell library for writing CGI programs.
 license:            BSD3
@@ -9,7 +9,8 @@
 author:             Bjorn Bringert
 maintainer:         John Chee <cheecheeo@gmail.com>, Peter Simons <simons@cryp.to>
 tested-with:        GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.5, GHC == 8.8.4,
-                    GHC == 8.10.7, GHC == 9.0.2, GHC == 9.2.5, GHC == 9.4.4
+                    GHC == 8.10.7, GHC == 9.0.2, GHC == 9.2.8, GHC == 9.4.8, GHC == 9.6.6,
+                    GHC == 9.8.4, GHC == 9.10.1, GHC == 9.12.1
 category:           Network
 homepage:           https://github.com/cheecheeo/haskell-cgi
 bug-reports:        https://github.com/cheecheeo/haskell-cgi/issues
@@ -34,15 +35,16 @@
   other-modules:    Network.CGI.Accept
   hs-source-dirs:   src
   build-depends:    base        >= 4.9 && < 5
-                  , bytestring  < 0.12
-                  , containers  < 0.7
+                  , bytestring  < 0.13
+                  , containers  < 0.8
                   , exceptions  == 0.10.*
-                  , mtl         > 2.2.0.1 && < 2.3
+                  , mtl         > 2.2.0.1 && < 2.4
                   , multipart   >= 0.1.2 && < 0.3
                   , network-uri == 2.6.*
                   , parsec      >= 2.0 && < 3.2
-                  , time        >= 1.5 && < 1.13
-                  , xhtml       >= 3000.0.0 && < 3000.3
+                  , text        < 2.2
+                  , time        >= 1.5 && < 1.15
+                  , xhtml       >= 3000.0.0 && < 3000.5
   other-extensions: MultiParamTypeClasses
   default-language: Haskell2010
 
diff --git a/src/Network/CGI.hs b/src/Network/CGI.hs
--- a/src/Network/CGI.hs
+++ b/src/Network/CGI.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  Network.CGI
@@ -116,6 +117,17 @@
 import Text.XHtml (Html, renderHtml, header, (<<), thetitle, (+++),
                    body, h1, paragraph, hr, address)
 
+#if MIN_VERSION_xhtml(3000,3,0)
+import Data.ByteString.Builder (toLazyByteString)
+import qualified Data.Text.Lazy as LText
+import qualified Data.Text.Lazy.Encoding as LText
+import Text.XHtml (Builder)
+
+-- Taken from Text.XHtml.Internal
+builderToString :: Builder -> String
+builderToString = LText.unpack . LText.decodeUtf8 . toLazyByteString
+#endif
+
 -- | Run a CGI action. Typically called by the main function.
 --   Reads input from stdin and writes to stdout. Gets
 --   CGI environment variables from the program environment.
@@ -206,7 +218,11 @@
                    output text
            _ -> do setHeader "Content-type" (showContentType htmlType)
                    page <- errorPage c m es
+#if MIN_VERSION_xhtml(3000,3,0)
+                   output $ builderToString $ renderHtml page
+#else
                    output $ renderHtml page
+#endif
 
 -- | Create an HTML error page.
 errorPage :: MonadCGI m =>
diff --git a/src/Network/CGI/Monad.hs b/src/Network/CGI/Monad.hs
--- a/src/Network/CGI/Monad.hs
+++ b/src/Network/CGI/Monad.hs
@@ -37,7 +37,6 @@
 import Control.Monad.Writer (WriterT(..), tell)
 import Control.Monad.Fail (MonadFail(..))
 import Control.Monad.Trans (MonadTrans, MonadIO, liftIO, lift)
-import Data.Typeable
 import Network.CGI.Protocol
 
 
@@ -50,7 +49,6 @@
 
 -- | The CGIT monad transformer.
 newtype CGIT m a = CGIT { unCGIT :: ReaderT CGIRequest (WriterT Headers m) a }
-                        deriving (Typeable)
 
 instance (Functor m) => Functor (CGIT m) where
     fmap f c = CGIT (fmap f (unCGIT c))
diff --git a/src/Network/CGI/Protocol.hs b/src/Network/CGI/Protocol.hs
--- a/src/Network/CGI/Protocol.hs
+++ b/src/Network/CGI/Protocol.hs
@@ -45,7 +45,6 @@
 import qualified Data.ByteString.Lazy.Char8 as BS
 import Data.ByteString.Lazy.Char8 (ByteString)
 
-import Data.Typeable
 import Network.Multipart
 
 
@@ -86,7 +85,7 @@
 -- | The result of a CGI program.
 data CGIResult = CGIOutput ByteString
                | CGINothing
-                 deriving (Show, Read, Eq, Ord, Typeable)
+                 deriving (Show, Read, Eq, Ord)
 
 --
 -- * Running CGI actions
@@ -317,4 +316,3 @@
 --   returns the empty string if lookup fails.
 lookupOrNil :: String -> [(String,String)] -> String
 lookupOrNil n = fromMaybe "" . lookup n
-
