Turning a SpatRaster object to a SpatialGridDataFrame

How to convert a SpatRaster object (from the terra package) to a SpatialGridDataFrame object?

r <- terra::rast(matrix(runif(10), 5, 5))
as(r, "SpatialGridDataFrame")

> Error in as(r, "SpatialGridDataFrame") : 
  no method or default for coercing “SpatRaster” to “SpatialGridDataFrame”

You have to go through raster:

library(terra)
library(raster)

x <- terra::rast(matrix(runif(25), 5, 5))
y <- raster(x)
z <- as(y, "SpatialGridDataFrame")