As happens with classic WebParts in SharePoint Online (SPO), Microsoft is starting to roll out the ability to connect modern WebParts. In fact, currently it’s possible to connect the following out of the box modern WebParts:
The List WebPart and the List properties WebPart.
The Document Libray WebPart and the List Properties WebPart.
The Document Library WebPart and the File Viewer WebPart.
Then, to connect both WebParts we need to open the setting panel for the File Viewer WebPart. As you can see in the screenshot bellow, the option to connect that WebPart with the Document Library one is a little bit hidden. You need to click on the “…” on the settings panel so the “Connect to source” option shows up:
Once we clic on that option, the connection settings are displayed:
Finally, we only need to check that the connection between both WebParts works so when we select a file in the Document Library WebPart, that file is shown in the File Viewer WebPart.