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

auth-ui-vue

v0.1.1

Published

Supabase Auth UI is a pre-built Vue component for authenticating users. It supports custom themes and extensible styles to match your brand and aesthetic.

Downloads

145

Readme

Supabase Auth UI Vue 💚

Supabase Auth UI is a pre-built Vue component for authenticating users. It supports custom themes and extensible styles to match your brand and aesthetic.

This was built as my first step towards contributing to open source and is heavily inspired by Supabase Auth UI React

Demo

You can find a link to the hosted demo here.

Set up Auth UI 👷🏽‍♂️

Import the latest version of supabase-js and the Auth UI package

Using npm:

$ npm install @supabase/supabase-js auth-ui-vue

Using yarn:

$ yarn add @supabase/supabase-js auth-ui-vue

Import the Auth component

Pass supabaseClient from @supabase/supabase-js as a prop to the component.

<script setup lang="ts">
import { createClient } from "@supabase/supabase-js";
import { Auth } from "auth-ui-vue";
import "auth-ui-vue/dist/style.css";

const supabase = createClient("<INSERT PROJECT URL>", "<INSERT PROJECT ANON API KEY>");
</script>

<template>
    <Auth :supabase-client="supabase" />
</template>

This renders the Auth component without any styling. We recommend using one of the predefined themes to style the UI. Import the theme you want to use and pass it to the appearence.theme prop.

<script setup lang="ts">
import { createClient } from "@supabase/supabase-js";
import {
    Auth,
    // Import predefined theme
    ThemeSupa,
} from "auth-ui-vue";
import "auth-ui-vue/dist/style.css";

const supabase = createClient("<INSERT PROJECT URL>", "<INSERT PROJECT ANON API KEY>");
</script>

<template><Auth :supabase-client="supabase" /* Apply predefined theme */ :appearance="{ theme: ThemeSupa }" /></template>

Social Providers 📲

The Auth component also supports login with offical social providers.

<script setup lang="ts">
import { createClient } from "@supabase/supabase-js";
import { Auth, ThemeSupa } from "auth-ui-vue";
import "auth-ui-vue/dist/style.css";

const supabase = createClient("<INSERT PROJECT URL>", "<INSERT PROJECT ANON API KEY>");
</script>

<template>
    <Auth :supabase-client="supabase" :appearance="{ theme: ThemeSupa }" :providers="['google', 'facebook', 'twitter']" />
</template>

Props ⚡️

There are some props that are could be passed to props to the Auth component to determine its output | Prop | Description | Type | default | --- | --- | --- | --- | | supabaseClient | An isomorphic Javascript client for interacting with Postgres. | SupabaseClient | | socialLayout | This determines how the social providers show be displayed | horizontal \| vertical | vertical | | providers | This is an array of social providers that can be used by your users to sign up | Provider[] | | view | This determines what type of auth component is displayed | sign_in \| sign_up \| magic_link \| forgotten_password \| update_password | sign_in | | redirectTo | This determines where supabase should redirect to when users want to sign in with a magic link, sign in with a social provider or update password | undefined \| string | | onlyThirdPartyProviders | This determines whether to show the email and password mode of authentication when the providers props is set | boolean | false | | magicLink | This determines whether to show the 'Send Magic Link' anchor so users can sign in with magic link | boolean | false | | showLinks | This determines whether to show the links which users can use to change the view to either sign_up/sign_in, magic_link,forgotten_password | boolean | true | | localization | This determines how the auth component texts like label, placeholders, and anchors can be styled to match your design language| Localization | { lang: 'en' } | | appearance | This determines how the auth component can be styled to match your design | Appearance | | theme | This determines what variant of the theme passed to appearance.theme | default \| string | default |

External resources for props:

  • Check here to see how to initialise the SupabaseClient.
  • Check here for the list of Providers that can be passed to the providers prop.
  • Check here to see how the language of the auth component can be overwritten using the localization prop.
  • Check here to see how the auth component can be styled to match your design using the appearance prop.

Events 🌐

These are some of the events that are emitted by the Auth component when an auth operation is completed which can be listened to on the page/component where the Auth component is being used.

| Event Name | Description | Emitted Value | --- | --- | --- | | set-loading | This event is emitted when an auth operation begins and when it ends | loading: boolean | | signin-completed | This event is emitted when the user signs in into your app successfully | data: any | | signup-completed | This event is emitted when the user signs up on your app successfully | data:any | | magic-link-sent | This event is emitted when the user asks for a magic link to be sent to their email | | forgotten-password-completed | This event is emitted when the user wants to reset their password and link to do so is sent to their email | | update-password-completed | This event is emitted when the user successfully change their password to a new one |

Example:

<script setup lang="ts">
import { createClient } from "@supabase/supabase-js";
import { Auth } from "auth-ui-vue";
import "auth-ui-vue/dist/style.css";

const supabase = createClient("<INSERT PROJECT URL>", "<INSERT PROJECT ANON API KEY>");

function doSomething() {
    alert('Magic Link have being sent to your email.')
}
</script>

<template>
    <Auth 
        :supabase-client="supabase"
        @magic-link-sent="doSomething"
    />
</template>

Customization ✨

There are several ways to customize Auth UI:

Predefined themes

Auth UI comes with several themes to customize the appearance. Each predefined theme comes with at least two variations, a default variation, and a dark variation. You can switch between these themes using the theme prop. Import the theme you want to use and pass it to the appearence.theme prop.

<script setup lang="ts">
import { createClient } from "@supabase/supabase-js";
import {
    Auth,
    // Import predefined theme
    ThemeSupa,
} from "auth-ui-vue";
import "auth-ui-vue/dist/style.css";

const supabase = createClient("<INSERT PROJECT URL>", "<INSERT PROJECT ANON API KEY>");
</script>

<template><Auth :supabase-client="supabase" /* Apply predefined theme */ :appearance="{ theme: ThemeSupa }" /></template>

Currently there is only one predefined theme available, but I plan to add more as soon as Supabase does.

Switch theme variations

Auth UI comes with two theme variations: default and dark. You can switch between these themes with the theme prop.

<script setup lang="ts">
import { createClient } from "@supabase/supabase-js";
import { Auth, ThemeSupa } from "auth-ui-vue";
import "auth-ui-vue/dist/style.css";

const supabase = createClient("<INSERT PROJECT URL>", "<INSERT PROJECT ANON API KEY>");
</script>

<template><Auth :supabase-client="supabase" :appearance="{ theme: ThemeSupa }" /* Set theme to dark */ theme="dark" /></template>

If you don't pass a value to theme it uses the "default" theme. You can pass "dark" to the theme prop to switch to the dark theme. If your theme has other variations, use the name of the variation in this prop.

Override themes

Auth UI themes can be overridden using variable tokens. See the list of variable tokens.

<script setup lang="ts">
import { createClient } from "@supabase/supabase-js";
import { Auth, ThemeSupa } from "auth-ui-vue";
import "auth-ui-vue/dist/style.css";

const supabase = createClient("<INSERT PROJECT URL>", "<INSERT PROJECT ANON API KEY>");
</script>

<template>
    <Auth
        :supabase-client="supabase"
        :appearance="{
            theme: ThemeSupa,
            variables: {
                default: {
                    colors: {
                        brand: 'orange',
                        brandAccent: 'yellow',
                    },
                },
            },
        }"
    />
</template>

If you created your own theme, you may not need to override any of the them.

Create your own theme

You can create your own theme by following the same structure within a appearance.theme property. See the list of tokens within a theme.

<script setup lang="ts">
import { createClient } from "@supabase/supabase-js";
import { Auth } from "auth-ui-vue";
import "auth-ui-vue/dist/style.css"

const supabase = createClient(
  '<INSERT PROJECT URL>',
  '<INSERT PROJECT ANON API KEY>'
)

const customTheme = {
  default: {
    colors: {
      brand: 'hsl(153 60.0% 53.0%)'
      brandAccent: 'hsl(154 54.8% 45.1%)'
      brandButtonText: 'white',
      // ..
    }
  },
  dark: {
    colors: {
      brandButtonText: 'white'
      defaultButtonBackground: '#2e2e2e'
      defaultButtonBackgroundHover: '#3e3e3e'
      //..
    },
  },
  // You can also add more theme variations with different names.
  evenDarker: {
    colors: {
      brandButtonText: 'white',
      defaultButtonBackground: '#1e1e1e',
      defaultButtonBackgroundHover: '#2e2e2e',
      //..
    },
  },
}
</script>

<template><Auth :supabase-client="supabase" theme="default" /* can also be "dark" or "evenDarker" */ :appearance="{ theme: customTheme }" /></template>

You can switch between different variations of your theme with the "theme" prop.

Custom CSS Classes

You can use custom CSS classes for the following elements: "button", "container", "anchor", "divider", "label", "input", "loader", "message".

<script setup lang="ts">
import { createClient } from "@supabase/supabase-js";
import { Auth } from "auth-ui-vue";
import "auth-ui-vue/dist/style.css";

const supabase = createClient("<INSERT PROJECT URL>", "<INSERT PROJECT ANON API KEY>");
</script>

<template>
    <Auth
        :supabase-client="supabase"
        :appearance="{
            className: {
                anchor: 'my-awesome-anchor',
                button: 'my-awesome-button',
                //..
            },
        }"
    />
</template>

Custom inline CSS

You can use custom CSS inline styles for the following elements: "button", "container", "anchor", "divider", "label", "input", "loader", "message".

<script setup lang="ts">
import { createClient } from "@supabase/supabase-js";
import { Auth } from "auth-ui-vue";
import "auth-ui-vue/dist/style.css";

const supabase = createClient("<INSERT PROJECT URL>", "<INSERT PROJECT ANON API KEY>");
</script>

<template>
    <Auth
        :supabase-client="supabase"
        :appearance="{
            style: {
                anchor: { color: 'blue' },
                button: { background: 'red', color: 'white' },
                //..
            },
        }"
    />
</template>

Custom labels

There are currently 5 default localization which can be used with the localization.lang prop. They are en, ja, de_formal, de_informal, pt_br. You can also use custom labels with localization.variables. See the list of labels that can be overwritten.

<script setup lang="ts">
import { createClient } from "@supabase/supabase-js";
import { Auth } from "auth-ui-vue";
import "auth-ui-vue/dist/style.css";

const supabase = createClient("<INSERT PROJECT URL>", "<INSERT PROJECT ANON API KEY>");
</script>

<template>
    <Auth :supabase-client="supabase" /* highlight starts */ :localization="{ variables: { sign_in: { email_label: 'Your email address', password_label: 'Your strong password', },
    } }" /* Highlight ends */ />
</template>