Now 100x Faster

Read the latest from Gatsby CTO Kyle Mathews Re-introducing Gatsby, a Reactive Site Generator

ContactSign Up for Free
Community Plugin
View plugin on GitHub

Gatsby Wordpress Admin

What does it do?

Adds WP cookie authentication to your WP Gatsby site to keep you authenticated in WP and your frontend at the same time. Automatically creates a /login and /dashboard page to manage your content.

You can also import the custom useAuth hook anywhere in your application. It will return your user.

Getting Started

  1. yarn add gatsby-theme-headless-wordpress-admin

Required WP plugins

useAuth

Example usage

import { useAuth } from "gatsby-theme-headless-wordpress-admin";

const { auth } = useAuth();

useLogin

Example usage

import { useLogin } from "gatsby-theme-headless-wordpress-admin";

const [sendUserLogin, { data, error, loading, called }] = useLogin({
  onCompleted: (data) => {
    console.log({ data });
  },
  onError: (err) => {
    console.log({ err });
  },
});

<button
  onClick={() =>
    sendUserLogin({
      variables: { username: "your_username", password: "your_password" },
    })
  }
/>;
© 2022 Gatsby, Inc.