It's a common pattern: making your app invite only. But is it desirable? It all depends on your app.
You could ask new users on the website to request an invite by giving their email. Then, you can email users that are invited a code, which can be filled in on the app to get access. Let's call this invite-only
On the other hand, you could opt for the more simple choice of just showing the download button that leads to the app store, and not requiring new users to enter a code after downloading the app.
When I was in doubt on whether or not to keep the invite only option for my app, I found four advantages, but more disadvantages.
Firstly, if you make it invite-only, you collect emails of users. These emails can later be used (unless they opt-out) to send any valuable information to them, for example tips/tricks or big updates.
Secondly, people can start talking about your app in real life or on social media, because they want an invite. The app SuperHuman lets you post a tweet to ask for an invite if you just filled in your email, because users that already have the app can send instant invites.
Thirdly, making your app invite only makes it more measurable where users come from. For example, you could add a stream of traffic through ads with a specific code. All users that enter that code, come from the ad. There are of course other ways to follow your users and know where they come from; for example: Facebook Pixel works for Facebook ads. But for viral apps that are spread through word of mouth, there is no good way to measure different sources, except if you use an invite-only code and make different codes for every segment.
Fourthly, having an invite-only app makes your app look scarce. Scarce things are far more desirable. Because of this, people will talk about it faster and, maybe, will use it more.
These are all great benefits of making your app invite only and requiring new users to fill in their email on the website. However, there are als some costs, so choose wisely:
Firstly, requiring people to fill in an email on the website to get a link to the app, and requiring people to fill in a code inside the app are two steps where people can say 'nah' and stop. Two extra steps for users to churn! That's a big drawback.
Secondly, it may look spammy, and potential users don't always want to give you their contact information. It's a lot to ask.
Thirdly, and this is in my opinion the largest drawback: There may be potential users that don't find your app through an ad or web search, but through app store search. Also your app may get featured in the App Store. Not letting this stream of users into your app is a big problem. Especially if your app gets reviewed well a lot, you will get more and more traffic from within the app store directly.
In conclusion, it's something to think about, whether or not to make your app invite only. It depends greatly in how much people trust your site, and how prominent the app is in the app store itself.