# Can you create password protected pages in Builder?

**URL:** <https://forum.builder.io/t/can-you-create-password-protected-pages-in-builder/863>\
**Category:** Technical Questions\
**Created:** [August 11, 2021, 10:45pm UTC](https://forum.builder.io/t/can-you-create-password-protected-pages-in-builder/863 "2021-08-11T22:45:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![korey](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/korey/32/12_2.png) [@korey](https://forum.builder.io/u/korey)\
**Post date:** [August 11, 2021, 10:45pm UTC](https://forum.builder.io/t/can-you-create-password-protected-pages-in-builder/863/1 "2021-08-11T22:45:07Z")

</div>

Yes, but it depends on how “secure” you need your password protected page to be. By default, content management platforms like Builder take the content you enter and make it retrievable via API so that it can be displayed on your site or app. This means that if you publish a page in Builder, that content is now available publicly via API, so that everyone visiting your site gets to see the updated content.

If you need the content to be secure and only accessible by authorized users, you should take the approach outlined in this forum post using private keys: [Create Private Pages that are accessible only after authorization](https://forum.builder.io/t/create-private-pages-that-are-accessible-only-after-authorization/58).

Or, if you are creating a page that you just want to add some hidden content to, **and it is okay if people are able to dissect API requests or code to figure out what’s in the hidden content,** you can create a page in Builder and add an input with a hardcoded password field and have it only show the proper content when the correct password is entered. This content is not secure and can still be read by anyone, but it is **hidden** , which may be enough for your use case. Here is a Builder page that takes that approach (password is `secret-password`): [Super secret page](https://builder.io/fiddle/2ed3f6fa59f448e88628a4288562158b/view)

You can see that the content is hidden from view until you enter the correct password. To build a similar page, take a look at the source fiddle: [Builder.io: Drag and drop page builder and CMS](https://builder.io/fiddle/2ed3f6fa59f448e88628a4288562158b)

The main concept is that you add an input to the page, and attach a `change` handler to that input to set the current password to whatever the visitor has entered. Then, attach a click handler to a button that will set a `state` variable to show the protected content only if the password entered is correct.

---

<div class="post-metadata">

**Author:** ![Marea](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/marea/32/2174_2.png) [@Marea](https://forum.builder.io/u/Marea)\
**Post date:** [November 16, 2022, 4:05pm UTC](https://forum.builder.io/t/can-you-create-password-protected-pages-in-builder/863/2 "2022-11-16T16:05:36Z")

</div>

This way can i protect a screen/page and make it accessible only after that Stripe communicates the subscription has been actually paid ?

---

<div class="post-metadata">

**Author:** ![TimG](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/timg/32/714_2.png) [@TimG](https://forum.builder.io/u/TimG)\
**Post date:** [November 16, 2022, 8:15pm UTC](https://forum.builder.io/t/can-you-create-password-protected-pages-in-builder/863/3 "2022-11-16T20:15:13Z")

</div>

@Marea absolutely, there are ways you could achieve this in Builder. Generally, as Korey mentioned above, the logic around whether users have paid, or users are logged in, are handled within your app itself. So the most sure-fire way to handle auth or some restricted content would be to set up that logic in your app and then get and display content from Builder depending on that logic.

That being said, there are a number of ways you could ensure to show correct content based on a user’s attributes . Depending on your exact use case, I think there are at least 2 ways you could achieve this.

If you want entire pages to be visible only once some criteria is met, you could use [Targeting](https://www.builder.io/c/docs/targeting-with-builder) with a custom targeting attribute called something like `paidSubscription` or whatever you like. Then if you pass that value into your `<BuilderComponent />` calls as a userAttribute, the page would only ever be visible to users that satisfy that criteria. So if this was a React app, something like this:

```auto
//get your user's subscription status with some method within your app
const hasUserPaid = checkHasUserPaidSubscription();

//getting content, as on a server
const page = (
    await builder
      .get(myPageModel, {
        userAttributes: {
          url: currentUrl
          paidSubscription: hasUserPaid
        },
      })
      .toPromise()) || null;
...
//inside your render
<BuilderComponent model={myPageModel} content={page} options={ userAttribute} />

```

Or for client-side rendered content, you can just include:

```auto
//or if you are only doing client-side rendering:
builder.setUserAttributes({
  paidSubscription: hasUserPaid
});
...
<BuilderComponent model={myPageModel} />

```

If you just want to have certain sections or content on a given page or section model to display based on that same user attribute, you could pass that value into Builder as a data prop to add it to state:

```auto
//get your user's subscription status with some method within your app
const hasUserPaid = checkHasUserPaidSubscription();

<BuilderComponent model={myPageModel} data={hasUserPaid} />

```

Then, you would be able to access that value in state  
 ![Screen Shot 2022-11-16 at 12.13.12 PM](https://us1.discourse-cdn.com/flex020/uploads/builder/original/2X/8/8a2447fed1ef4d4abcf82479d2f92ec15230ebc0.png)

And use that data to set up [data bindings](https://www.builder.io/blog/builder-data) to hide or show content dynamically based on that value

Hopefully this helps! Let me know if you have any further questions!

---

<div class="post-metadata">

**Author:** ![Marea](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/marea/32/2174_2.png) [@Marea](https://forum.builder.io/u/Marea)\
**Post date:** [December 9, 2022, 11:37am UTC](https://forum.builder.io/t/can-you-create-password-protected-pages-in-builder/863/4 "2022-12-09T11:37:53Z")

</div>

Yes it does , sorry for the late reply , while i’m not so skilled i will practice on this , thank you so much.
