xtrareports-405327-web-reporting-react-reporting-document-viewer-document-viewer-integration-react-vite.md
Important
Familiarity with React basic concepts and patterns is essential prior to the use of this documentation. If you require a review, please refer to React documentation for a getting-started tutorial
The Web Document Viewer is used in applications that contain client and server parts:
ClientA Web Document Viewer integrated in a client React application displays a report provided by the server-side model.ServerThe server is an ASP.NET Core application that handles client data requests and provides access to data sources, report storage, and other back-end capabilities.
This tutorial creates and configures a client React application and a server ASP.NET Core backend. The client is created with the help of Vite and contains the Web Document Viewer control.
Tip
You can also use our DevExpress project templates to create a React Reporting application:
Note the following details about package versions:
You can use DevExpress CLI Templates to create an ASP.NET Core back-end application. Begin with the steps below:
Install DevExpress ASP.NET Core project templates from nuget.org:
Create a back-end Reporting application for a Document Viewer:
Enable cross-origin requests (CORS). Specify the policy that allows any local application to access the report’s back-end. Use the SetIsOriginAllowed method to set it up.
To run the server-side application, run the following command:
To create a back-end application from a Microsoft or DevExpress Template in Visual Studio, review the following help topics:
In the command prompt, create a React application:
Navigate to the project folder:
Install the devexpress-reporting-react npm package:
Open the src/App.tsx file and substitute its contents with the following code excerpt:
Remove default project styles to avoid conflicts. To do this, remove the index.css import in main.tsx.
Run the server application.
Run the client application:
Open your browser and navigate to the URL specified in the command output to see the result:
You may encounter the following problems:
The Document Viewer page is blank. The following error message is displayed at the bottom of the page:
Could not open report ‘TestReport’
Check the following:
host setting of the Document Viewer component.reportUrl setting value matches an existing report. For the backend application, ensure that either the Reports folder contains a reportUrl.repx file or the ReportsFactory.Reports dictionary contains the reportUrl entry (if the back-end application originated from the DevExpress template).Refer to the following topic for more information: Troubleshooting.
Specify Parameter ValuesSpecify Parameter Values through the Document Viewer’s UI or code.Customize the ToolbarCustomize the Document Viewer Toolbar: hide export formats, customize toolbar commands.Customize the Tab Panel Customize the Document Viewer Tab Panel: remove the Tsb Panel, add new tabs to the Panel. Customize Parameter Editor : Customize a standard parameter editor in the Web Document Viewer. See Also