While Clerk does not provide a geo blocking feature, deployment platforms, such as Vercel and Render, expose geolocation data through request headers. This allows you to implement custom geo blocking logic by accessing the client's location data at runtime and conditionally allowing or blocking requests based on your requirements.
Vercel
Render
The following example shows how to implement geo blocking in your clerkMiddleware() using Vercel's geolocation() function. If a user visits any route that is not a /block route, the middleware checks the client's country and redirects to the /block route if the country is not allowed. If that route is protected, the middleware also checks if the user is authenticated.
The following example shows how to implement geo blocking in your clerkMiddleware() using Render's cf-ipcountry header. If a user visits any route that is not a /block route, the middleware checks the client's country and redirects to the /block route if the country is not allowed. If that route is protected, the middleware also checks if the user is authenticated.