MCPcopy Create free account
hub / github.com/clerk/javascript / createProtect

Function createProtect

packages/nextjs/src/server/protect.ts:27–110  ·  view source on GitHub ↗
(opts: {
  request: Request;
  authObject: AuthObject;
  /**
   * middleware and pages throw a notFound error if signed out
   * but the middleware needs to throw an error it can catch
   * use this callback to customise the behavior
   */
  notFound: () => never;
  /**
   * see {@link notFound} above
   */
  redirect: (url: string) => void;
  /**
   * protect() in middleware redirects to signInUrl if signed out
   * protect() in pages throws a notFound error if signed out
   * use this callback to customise the behavior
   */
  redirectToSignIn: RedirectFun<unknown>;
})

Source from the content-addressed store, hash-verified

source not stored for this graph (policy: none)

Callers 2

authFunction · 0.90
createMiddlewareProtectFunction · 0.90

Calls 2

handleUnauthenticatedFunction · 0.85
handleUnauthorizedFunction · 0.85

Tested by

no test coverage detected