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 = ; const handleSubmit = const username password = values; const body = username password ; const res = await ; if reserror console; else // Update our Userbase Context ; // You might want to navigate the user to the account page here ; ; // 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. */ ; // Example with Promiseconst handleForgottenPassword = { ;}; // Async/Await Exampleconst handleForgottenPassword = async { try const user = await ; // email with temporary password sent console; catch e console; };
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.