Skip to content


Repository files navigation

Gatsby Theme Netlify Identity

This repo is a yarn workspace.


  • ✅Add Netlify Identity Authentication to any Gatsby app
  • 🕵🏼‍Shadow only the components you need to add authentication to
  • ♿ Accessible modal component that doesn't require a UI redesign unless you want to
  • 💁🏼‍♂️Drop down to use the headless react-netlify-identity API if you want to write your own auth UI

How to Use In Your Gatsby App

⚠️ Make sure to enable Netlify Identity on your site!

this theme adds gatsby-plugin-netlity-identity for you and ships some nice components!

yarn add gatsby-theme-netlify-identity

And add it to your config:

// In your gatsby-config.js
module.exports = {
  plugins: [
    // You can should only have one instance of this plugin
      resolve: `gatsby-theme-netlify-identity`,
      options: {
        url: ``, // required! Make sure Identity is enabled!

Now you can use IdentityModal and useIdentityContext in your application!

import React from 'react'
import IdentityModal, { useIdentityContext } from 'react-netlify-identity-widget'
import 'react-netlify-identity-widget/styles.css' // delete if you want to bring your own CSS

const Layout = ({ children }) => {
  const identity = useIdentityContext()
  const [dialog, setDialog] = React.useState(false)
  const name =
    (identity &&
      identity.user &&
      identity.user.user_metadata &&
      ( || identity.user.user_metadata.full_name)) ||

  const isLoggedIn = identity && identity.isLoggedIn
  return (
      <nav style={{ background: 'green' }}>
        {' '}
        Login Status:
        <button className="btn" onClick={() => setDialog(true)}>
          {isLoggedIn ? `Hello ${name}, Log out here!` : 'LOG IN'}
      <IdentityModal showDialog={dialog} onCloseDialog={() => setDialog(false)} />

export default Layout


this project also converted into a theme.

Local Development

yarn workspace demo develop

The demo will start at http://localhost:8000

NOTE: If you’re new to Yarn workspaces, check out this post for details.