How to show or hide elements for signed-in visitors
In a TeleportHQ web app with sign-up and login, a condition can read who is looking at the page. The Select Dynamic Property panel lists two built-in values under global: User is logged in, which is true or false, and Current User, with the member's name, email, role, image and more. A Sign out button gets the rule User is logged in = true, a Sign in link gets = false, and a Manage orders button for staff gets Current User → role = admin.
Before you start
- Sign-up and login must be on. Without it, User is logged in and Current User are not in the panel. Turning it on makes the project a web app. See How to add sign-up and login to your site.
- For role rules, your users need roles. See How to manage your site's users and roles.
- Role. You need a role that can edit the project, for example Designer.
Steps
The example shows a Sign out button to signed-in visitors and a Sign in link to everyone else.
1. Show the Sign out button to signed-in visitors
- On the canvas, select the Sign out button in your navigation.
- In the right panel → Visual tab, turn on the Conditional Rendering switch.
- Click Bind, then Dynamic Properties Assignment Panel.
- In the Select Dynamic Property panel, open global, click User is logged in, then click Bind property.
- Keep
=in the Operand list. In the value list, picktrue.
2. Show the Sign in link to everyone else
- Select the Sign in link.
- Turn on Conditional Rendering, click Bind → Dynamic Properties Assignment Panel → global → User is logged in → Bind property.
- In the value list, pick
false.
3. Show a button to one role only
- Select the button, for example Manage orders.
- Turn on Conditional Rendering, click Bind → Dynamic Properties Assignment Panel, open global → Current User, click
role, then Bind property. - Keep
=and type the role in the value box, for exampleadmin.
The same works with any field of Current User: id, name, email, emailVerified, image, role, and the custom properties you added to your users table.
Check that it worked
On the canvas, click the padlock button at the top left (it reads Logged Out until you pick someone) and choose Act as User, then a user. Elements with User is logged in = true appear, and those with = false disappear. Choose Act as Logged Out to see the page as a guest again. See How to preview your site as a signed-in user.
Then publish and open the page in a private browser window: you see the guest version. Sign in: you see the member version.
Troubleshooting
User is logged in isn't in the panel Sign-up and login aren't on in this project. Turn them on first.
Everything shows on the canvas, whatever the condition Check the padlock button. It shows the name of the user the canvas acts as, or Logged Out. The condition reads that choice.
The role rule never matches The role is compared as text, exactly as it is stored: admin and Admin are different. Open the user's row in Manage Settings & Users to read it.
The hidden block is still on the page for guests Give it time to publish, then reload the page in a private window. A condition only reaches your live site when you publish.
Good to know
- A condition hides, it does not protect. A block with User is logged in
=trueis left out of the page for guests. The page itself stays public, and a link's target page stays reachable. For a page only members may open, turn on Require Authentication and, for a role, Role Protection. See How to make a page visible only to signed-in users. - Ready-made elements. Elements → Primitives holds Account elements such as Sign Out and Name, which show the signed-in member's details without a condition. See How to show the signed-in user's name, photo and details.
- One rule, two elements. A navigation often holds both a Sign in link (
= false) and a Sign out button (= true). Both read the same value. - Downloaded code. Conditions on the signed-in visitor need the Next.js download; the HTML download has no sign-in. See How to download your site as code.