Conditions

How to show or hide elements for signed-in visitors

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

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

  1. On the canvas, select the Sign out button in your navigation.
  2. In the right panel → Visual tab, turn on the Conditional Rendering switch.
  3. Click Bind, then Dynamic Properties Assignment Panel.
  4. In the Select Dynamic Property panel, open global, click User is logged in, then click Bind property.
  5. Keep = in the Operand list. In the value list, pick true.
  1. Select the Sign in link.
  2. Turn on Conditional Rendering, click Bind → Dynamic Properties Assignment Panel → global → User is logged in → Bind property.
  3. In the value list, pick false.

3. Show a button to one role only

  1. Select the button, for example Manage orders.
  2. Turn on Conditional Rendering, click Bind → Dynamic Properties Assignment Panel, open global → Current User, click role, then Bind property.
  3. Keep = and type the role in the value box, for example admin.

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 = true is 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.
Share

Related Articles

What are conditions?

In TeleportHQ, a condition is a rule on one element, such as "show this badge while stock equals 0" or "show this menu while isMenuOpen is true"; you set it in the Conditional Rendering section of the right panel, it can read a state, a component setting, a list item, the signed-in visitor, the cart or a URL parameter, and on the published site the element is left out of the page while the rule is false.

How to show or hide elements based on a condition

In TeleportHQ, you show an element only when a condition is true, such as "stock equals 0" or "the menu is open", by selecting it, turning on the Conditional Rendering switch near the top of the right panel and building the condition from a value, an operator and a comparison value; it works in every project, website or web app.

How to show or hide elements by state

In TeleportHQ, create a state in Page settings → State (for example isMenuOpen, true or false), give the element a Conditional Rendering rule such as isMenuOpen = true, and change the state from a button's Events tab with Change State; it works on websites and web apps and needs no web app features.

How to show or hide elements by URL parameter

In TeleportHQ, declare the parameter on the page under Page Params in Page settings (a Key name such as category and a Default value), then give the element a Conditional Rendering rule on the URL Param, such as category = cakes; a visitor who opens /products?category=cakes sees that element, and the page without the parameter uses the default.

How to show or hide elements by cart and store values

In a TeleportHQ store, the Select Dynamic Property panel lists the visitor's cart under global → E-commerce → Cart (itemCount, total, shippingIsFree, freeDeliveryRemaining and more) and the store's Settings; a rule such as shippingIsFree = false shows a "Spend more for free delivery" banner, itemCount = 0 an empty-cart message, and a product's stock field a "Only 3 left" label.

How to use conditions in components and variants

In TeleportHQ, a condition inside a component can read one of the component's settings (props): click Bind in the Conditional Rendering section and choose Create Conditional Prop, and every copy of the component then turns that part on or off, or picks a look, under Component Properties → Conditional; one card component gets several looks without being duplicated.

Condition recipes

Six ready-to-copy TeleportHQ conditions, each with the state or value to create and the rule to set: an accordion and tabs built from a state (or the Accordion and Tabs elements that do it for you), an image slider with a slide state, a "no results" message with is_empty, a language-specific block on Current Language → short, and a fallback for a missing field.