Awesome!
Let me get to your answers then.
Can you develop locally with Netlify Identity?
Yes! But it’s not super straightforward when it comes to setting up a new account from your local dev. For starters, it’s critical to be aware that your site gets one Netlify Identity instance, and that instance is shared between any and all environments. Developing with Netlify Identity locally means that you’ll be hitting your production Identity instance. I don’t consider this a very big deal, it doesn’t grant you any sort of ability to muck with your production data, but it’s good to know.
So when actually using Netlify Identity in local development, there are two ways to get started. First, you can just log in with the same credentials you use on your production environment. Since it’s the same underlying Identity instance, you should be able to login without issue. If you don’t have a registered user in your Identity instance, you can follow the registration steps locally, but you need to use your command line. When you register for an account, whether locally or on your production environment, you are sent a confirmation email. Two options at this point:
- Click that link and confirm your account then switch back to your local dev server and log in with that account
- Don’t click, copy that link and hit from your favorite command line HTTP client (I use httpie). It should be a
mandrillapp.com
link. You should see a redirection take place and a Location:
header come back with your production URL and a confirmation_token
:
dev$ http https://mandrillapp.com/track/click/31128206/random-site-name.netlify.app?p=eyJzIjoidVZVUTZKUTlHS2t1MURaLXo4cnJ5QkN0c28wIiwidiI6MSwicCI6IntcInVcIjozMTEyODIwNixcInZcIjoxLFyY2U2MzQxZmI0ZjMyODQyYTVkZmJhZDJlZjQ0N1wiLFwidXJsX2lkc1wiOltcIjBjZjc3MGFhYmVkOThjODQ1YTkzMGUwMTZlZmRjOTEzYjY0Yzk0ZTJcIl19In0
HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: mandrillapp.com
User-Agent: HTTPie/2.3.0
HTTP/1.1 302 Moved Temporarily
cache-control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
content-encoding: gzip
content-type: text/html; charset=utf-8
date: Tue, 29 Dec 2020 07:24:04 GMT
expires: Thu, 19 Nov 1981 08:52:00 GMT
location: https://random-site-name.netlify.app/#confirmation_token=UIs1dRjxAzWxqNB1FFZDVQ
pragma: no-cache
server: nginx/1.4.6 (Ubuntu)
transfer-encoding: chunked
vary: Accept-Encoding
In this case, it’s the https://random-site-name.netlify.app/#confirmation_token=UIs1dRjxAzWxqNB1FFZDVQ
above. If you take off the https://random-site-name.netlify.app
and replace it with localhost:YOUR_PORT
, you can achieve the confirmation process purely from local development.
In terms of other helpful options for making Netlify Identity more integrated with your site, I actually just released react-netlify-identity-gotrue
, which adds pure-React bindings for Identity into any React app (including Gatsby and Next, etc.). Check it out, it may help you have a simpler dev process since you’re using React
Hope that helps!
–
Jon