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

gatsby-theme-user-base

v0.1.2

Published

A Gatsby Theme to incorporate Userbase into your Gatsby website.

Downloads

3

Readme

Gatsby Theme Userbase

Thanks for checking out my project. This theme is designed to assist with the integration of a new serverless user management system called Userbase.

Example

To see a working example of the theme in action then feel free to take a look at the rough and ready starter project that I have added to this repo in starters/gatsby-user-base-starter.

Credits

There is another Userbase theme developed by dayhaysoos. This theme takes a lot of inspiration from their project. I decided to run with my own version of a theme for the purpose of learning and I wanted to take this theme in a different direction as it will be used as part of a personal project.

Why use this theme?

The theme is equipped with a Provider that will give you a central store for persisting a Userbase session across pages. The theme will also provide you with a handful of utility methods that makes handling Userbase requests a little bit easier for you.

For example, let's assume you want to create a submission callback function that will let a user log into their account.

import { navigate } from "gatsby";
import { signIn, useUserbase } from "gatsby-theme-user-base";

const LoginForm = () => {
  const [state, dispatch] = useUserbase();

  const handleSubmit = async (values) => {
    const { username, password } = values;
    const body = { username, password };

    const res = await signIn(body);

    if (res.error) {
      console.log(`Oops! Something went wrong: ${res.error}`);
    } else {
      // Update our Userbase Context
      dispatch({ type: "setUser", payload: res.user });

      // You might want to navigate the user to the account page here
      navigate("/account");
    }
  };

  // The rest of your form...
};

Available Helpers

This project is in it's very early stages, so functionality is limited. If I haven't provided a helper for a Userbase method that you need, then don't worry, you can still access the Userbase library directly.

/**
 * Forgot Password is a method that we currently have
 * no helper for. Therefore, you won't be able to import
 * this from the `gatsby-theme-user-base` package.
 */

import { forgotPassword } from "userbase-js";

// Example with Promise
const handleForgottenPassword = ({ username }) => {
  forgotPassword({ username })
    .then((user) => {
      // email with temporary password sent
      console.log("this is user", user);
    })
    .catch((e) => console.error(e));
};

// Async/Await Example
const handleForgottenPassword = async ({ username }) => {
  try {
    const user = await forgotPassword({ username });
    // email with temporary password sent
    console.log("this is user", user);
  } catch (e) {
    console.error(e);
  }
};

List of Helpers

The following helpers have been developed and tested:

  • init
  • signUp
  • signIn
  • signOut

The following helpers are to be included within the theme and are yet to be worked on:

  • forgotPassword
  • updateUser
  • deleteUser

What about Stripe Payments?

I haven't incorporated Userbase Payments into the theme at this stage. For the time being I start with the basics and then increment over time. However, as with the forgot password example shown above, you will still be able to leverage the Userbase SDK and integrate this into your Gatsby website accordingly.

Please refer to the Userbase SDK documentation for further information.