Adding Read-Only Access For Users

Configure your Knack app so users can view records without the ability to edit or delete them, using user roles, connections, and login-protected pages.

What You'll Learn

  • How to set up a user role with view-only access
  • How to connect user records to data tables
  • How to create a login page that displays records without edit or delete options

Use Case

Your application stores records that you want users to view but not modify. For example, an app that stores Order records where Customers can log in and view their Orders but can't edit or delete them.

Requirements

  • Your app includes a table that stores the records you want users to view (e.g., an "Orders" table)
  • User logins are activated with at least one defined user role

Steps

First, create a user role and a login page for those users. Then add read-only elements like tables and details that let users view records without edit or delete options.

Adding a User Role

If you don't have a user role already, add one from the Data section of the Builder. Click the + button in the user role section at the bottom of the left column.

Once you've added your user role, add at least one user record to log in and test.

Connect the Table to the User Role

Connection fields link records from different tables together. Add a connection so each Order record can be connected to a Customer.

  1. In the Data section, select the Orders table from the left menu.
  2. Click the + button in the Connections column to add a new connection field.
  1. In the connection setup modal, select Customer as the table to connect to.
  1. Click Next to proceed to the connection type. Keep the default settings so each Order connects with one Customer, and each Customer can connect with many Orders.
  1. Click Add Connection to save. A Customer connection field now appears on the Order table.
  1. In the Records section, update the Order records by clicking on the empty Customer cells to look up and select a Customer.

Adding a New Page Displaying Records

Now create a page where users can view their records but not edit them.

📘

The key to read-only access

Don't add any forms, action links, or inline editing to the page. Without these, users can view records but can't make changes.

  1. In the Pages section, click + to add a new page and select Login Page.
  1. Choose Limit permissions to specific user roles and select the Customer user role.
  1. Select an element type and which table's records to display. For example, select a table element displaying Order records.
  1. When prompted to add additional links to the element, do not select "edit each record with a form." This keeps the view read-only.

Login and Test

  1. Click Preview or Go to Live App in the top right corner.
  1. Log in with your test Customer credentials. The logged-in Customer will see a table listing any Orders connected to their account. Each Order can be clicked to view more details, but there are no options to edit.

Read-Only Access Without Logins

You don't need logins to make records read-only. The key is making sure there are no edit forms, inline editing on tables, or action links on your elements. Without these, users can view records but can't make changes, regardless of whether they're logged in.

Next Steps