⚠️
The vite-plugin-ssr project has been renamed Vike.
  • If you are already using vite-plugin-ssr, then migrate to Vike.
  • For new projects, don't use vite-plugin-ssr but use Vike instead.
It follows the same philosophy: Vike itself (without extensions) is unopinionated and lets you integrate tools with architectural freedom.

Guard

The guard() hook enables you to protect pages.

The most common use cases being authentication and authorization, see Guides > Authentication > Login flow.

Note that:

  • It's always used together with throw render() or throw redirect(). (The guard() hook doesn't accept any return value.)
  • It can be asynchronous. (Unlike Route Functions which are always synchronous.)
  • A single guard() hook can apply to multiple pages. (By using the usual inheritance rules.)