⚠️
The vite-plugin-ssr project has been renamed Vike.
  • If you are using vite-plugin-ssr, migrate to Vike.
  • For new projects, use Vike instead of vite-plugin-ssr.
Vike itself (without extensions) is like vite-plugin-ssr: unopinionated and fully agnostic.

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.)