Build a Home Page for a Losant Experience

In the previous part of this walkthrough, you learned how to create a login page to allow your Experience Users to authenticate against your custom experience. This part expands your experience to include a custom home page that only logged-in users can see.

Home Page Screenshot

Step One: Create an Experience View

The first step in building the home page is to create the view with the content.

Home Content

Set the Layout to the layout you created earlier in this walkthrough and set the Page Type to Custom.

Here is the page content:

{{#fillSection "metaDescription"}}This is an example home page for your application experience.{{/fillSection}}
<div class="container">
  <div class="jumbotron">
    <h1>Your Experience View!</h1>
    <p class="lead">
      This is an example <a target="_blank" href="">Experience View</a> we've built for you. It provides many of the common
      components that most web pages have, like a header, footer, and navigation. You can use this
      as a launching point for your own custom user interfaces.
    All Experiences Views start with a <a href="">Layout</a>. The layout includes common items found on
    all pages, like a header and footer. <a href="">Pages</a> are then rendered inside
    the layout.
  <p>There are two types of pages available: <a target="_blank" href="">Custom</a> and <a target="_blank" href="">Dashboard</a>.
    What you're reading now is an example of a custom page. Dashboard pages allow you to embed an
    existing dashboard, which is a fast way to publish data to your Experience Users.
    For additional information, please read the <a target="_blank" href="">Experience View Walkthrough</a>, which includes
    detailed instructions for how to build a complete example that includes both custom and
    dashboard pages.
    This example is created using <a href="" target="_blank">Twitter Bootstrap</a>, which
    provides many components, styles, and utilities that make building web pages simple.

Copy/paste above into your new page.

This home page example is mostly Twitter Bootstrap markup for laying out the content, plus a {{#fillSection}} helper similar to what was part of the Log In page.

Step Two: Create the Experience Endpoint

Next, create the endpoint that returns the page you just created.

Home Endpoint

Set the Method / Route to / and set the Access Control to Any authenticated user.

Step Three: Use Static Replies

Next, you need to use static replies. When your endpoint does not need complicated logic, you can use static replies to immediately redirect or render a page (and so you don’t need to create a workflow).

Home Endpoint Static Replies

In this case, there are two static replies:

  • One for when there is an authenticated user.
  • One for when there is not.

In the case where there is no authenticated user, the Unauthorized Reply redirects to /login to force the user to log in. In the case where there is an authenticated user, it replies directly with the page that you created above, the Home Page.

Now that the page and endpoint with static replies are created, your home page route will work. If you request the / route while not logged in, you’ll be redirected to /login. At that point you can log in and then you’ll be redirected back to / to view your home page content.

What’s Next

This completes this part of the walkthrough. The following parts of this walkthrough will begin adding additional functionality that is common to most web pages.

Was this page helpful?

Still looking for help? You can also search the Losant Forums or submit your question there.