How to Connect Two Anvil Apps (Homepage and Product App)

Hi everyone,

I’m working on a project with two Anvil apps:

  • App A: A homepage/landing app (with login functionality)
  • App B: The actual product app users access after logging in

I’d like to implement the following flow:

  1. Users land on App A, which handles login/signup.
  2. After successful login, they are redirected to App B.
  3. Ideally, their login session (or at least authentication status) is recognized in App B.

What’s the best way to securely link these two apps and manage authentication across them? Should I use HTTP endpoints, pass tokens, or is there a built-in Anvil feature for this?

Thanks in advance for any tips or best practices!

– Anna

I think you could use App B as a dependency and it would be fine

If you share the users data table between both apps, the login will also be shared. You just need to tick “Share login status with other apps” in the Users service in the Editor.

5 Likes

@divyeshlakhotia already gave the right solution: set up the Users service in both apps, delete the Users table from the second app, and link it to the shared Users table from the first app. Then make sure “Share login status with other apps” is enabled.

One extra tip: App A can serve as a central portal with links to App B and any future apps. I use a portal app myself, which lists dozens of other apps, with access controlled by user permissions.

Each app can simply check if a user is signed in, and redirect to App A if not. I use a more modular setup with a HeaderWithLogin custom component that I include in the header of every app. This component handles login, shows the current user, and exposes helper methods for checking permissions. So when I create a new app, I just add the Users service, connect it to the shared table, drop in HeaderWithLogin, and user management is ready to go.

This is a bit different from @duncan_richards12’s suggestion. Instead of making App A a depending on the other apps, I keep the dependency limited to the HeaderWithLogin component. This keeps App A lean and makes the setup more scalable across multiple apps. Also, I have a distinct URL per app.

5 Likes