npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nuxtjs/hanko

v0.7.0

Published

Hanko integration for Nuxt

Downloads

176

Readme

Nuxt Hanko

npm version npm downloads Github Actions Codecov

Hanko integration for Nuxt

Features

  • ✨ Easy integration for Hanko
  • 🧱 Type safety and auto-registration for Hanko web components
  • 💪 Server utilities for full-stack auth

Installation

Install and add @nuxtjs/hanko to your nuxt.config.

npx nuxi@latest module add hanko
export default defineNuxtConfig({
  modules: ['@nuxtjs/hanko'],
  hanko: {
    // You can also configure this by setting NUXT_PUBLIC_HANKO_API_URL at runtime
    apiURL: '<YOUR_API_URL>',
    // You can also customise these if required
    // cookieName: 'hanko'
    // redirects: {
    //   login: '/login',
    //   success: '/',
    //   home: '/',
    //   followRedirect: true
    // },
    // registerComponents: true,
    // augmentContext: true,
  },
})

Usage

Components

To use, you can use the Hanko components anywhere in your app: <hanko-auth>, <hanko-events> and <hanko-profile>. These are web components that will be rendered on the client-side only. Props are typed.

You can turn auto-registration of components off (if you wish to use Hanko just on the server side or programmatically) with registerComponents: false.

Check out the Hanko documentation to learn more.

<template>
  <hanko-auth />
</template>

Middleware

By default two new route middleware are available in your Nuxt app: hanko-logged-in and hanko-logged-out.

  • hanko-logged-in will prevent access to a page unless you are logged in. (It will redirect you to redirects.login instead, and then redirect back to this page once you login. You can disable this behaviour by setting redirects.followRedirect to false.)
  • hanko-logged-out will prevent access to a page unless you are logged out. (It will redirect you to redirects.success when you log in, and otherwise to redirects.home.)

You can also create your own middleware for full control.

Auto-imports

useHanko is exposed in the Vue part of your app to allow you direct access to the Hanko API. You can access the current user and much more. Note: It will return null on the server.

Server utilities

By default you can access a verified JWT context on event.context.hanko. (It will be undefined if the user is not logged in.) If you want to handle this yourself you can set augmentContext: false.

verifyHankoEvent is exposed in the Nitro part of your app to expose the underlying utility used to create event.context.hanko if you want to handle things manually.

💻 Development

  • Clone this repository
  • Enable Corepack using corepack enable
  • Install dependencies using pnpm install
  • Stub module with pnpm dev:prepare
  • Run pnpm dev to start playground in development mode

Credits

Thanks to @McPizza0 for the push to make the module!

License

Made with ❤️

Published under the MIT License.