React Netlify Identity Widget
The easiest way to use Netlify Identity with React, no login UI coding required!
This is a React port of https://github.com/netlify/netlify-identity-widget (48kb), taking the lightweight functionality of https://github.com/sw-yx/react-netlify-identity (4kb) and adding back the nicer UI with a focus on accessibility (with @reach UI) and bundle size (only 6kb as of writing).
demo
the demo is hosted at: https://react-netlify-identity-widget.netlify.com (you can see the deploy logs here)
and the source is in /examples
.
Usage
we require some peer dependencies:
yarn add react-netlify-identity-widget @reach/dialog @reach/tabs @reach/visually-hidden
and the styles are optional but provided. here's how to use IdentityModal, useIdentityContext, IdentityContextProvider
:
You may also code split the Modal if you wish with React.lazy
and React.Suspense
.
Blogposts
Gatsby plugin
You may get a little help configuring RNIW for usage with Gatsby by using https://github.com/sw-yx/gatsby-plugin-netlify-identity. Read its README for more info.
local dev
yarnyarn buildyarn linkcd exampleyarn && yarn link "react-netlify-identity"yarn start # to see the example run
tsdx bug
we use https://github.com/ds300/patch-package to patch this bug https://github.com/jaredpalmer/tsdx/issues/36
List of Alternatives
Lowest level JS Library: If you want to use the official Javascript bindings to GoTrue, Netlify's underlying Identity service written in Go, use https://github.com/netlify/gotrue-js
React bindings: If you want a thin wrapper over Gotrue-js for React, react-netlify-identity
is a "headless" library, meaning there is no UI exported and you will write your own UI to work with the authentication. https://github.com/sw-yx/react-netlify-identity. If you want a drop-in UI, there is yet another library that wraps react-netlify-identity
: https://github.com/sw-yx/react-netlify-identity-widget
High level overlay: If you want a "widget" overlay that gives you a nice UI out of the box, with a somewhat larger bundle, check https://github.com/netlify/netlify-identity-widget
High level popup: If you want a popup window approach also with a nice UI out of the box, and don't mind the popup flow, check https://github.com/netlify/netlify-auth-providers