How to list documents on a SharePoint page?

There are many ways to list documents on a page in SharePoint. None of the approaches described below require that the documents are stored in the same site as the page and in all approaches you can use the same search syntax in the web parts as you would use in MetaShare.

Using search

Highlighted content web part

The highlighted content web part is included, out of the box, in standard SharePoint. It uses search to present content that match your search criteria. It has a few options for presentation and you can either use the simplified settings or build a custom query depending on your needs:
Highlighted content web part
For more information about this web part, read this Microsoft support page: Use the Highlighted content web part.

PnP Modern Search

PnP Modern Search are third party web parts that are developed and supported by the community. They are much richer in functionality than the Highlighted content web part but are also much more complicated to set up. Most notably you have full control over presentation using Handlebars templates. It also includes search box, refinement and verticals web parts. Together these can be used to build a complete custom search experience on modern pages.

The package and its future updates need to be installed by a global administrator. Read more in their getting started guide.

Building search query

When listing documents using search it is important to know that documents of some file types are not recognized as documents in search. These file types are indexed differently, which can lead to incorrect results, if the search query relies on IsDocument or Path properties. IsDocument property will only be true for files with limited number of extensions recognized by search, so it is better to use it together with contentclass property and search for items located in Document Libraries:

(IsDocument=1 OR contentclass=STS_ListItem_DocumentLibrary)

Path property for these documents will not include the URL of the file, but an URL to it’s properties form. Because of that when querying for documents in a specific folder ParentLink property should be used instead of Path.

Embed MetaShare

Any page in MetaShare can be embedded on a SharePoint page using the Embed web part.

First you must ensure that the domain is allowed to be embedded in your SharePoint site. Read more in Office support.

Then you can add the Embed web part to a page. The embed code should look similar to this:

<iframe src="$embedded=true" width="760" height="350"></iframe>

If you add &$embedded=true in the query string, (the part of the src after the question mark (?)), MetaShare will be displayed without showing it’s left- and top navigation.

The downside with this approach is that iframe elements have fixed width and height so the user may see scroll bars in the content area of the page.