Base solution for your next web application
Open Closed

Jquery and React version #12705


User avatar
0
ashgadala created

Hi Team, We are currently using the jQuery version of ASP.NET Zero and are exploring the possibility of migrating to the React version. I realize this is a broad question, but as we are in the early stages of our decision-making process, we would like to know if this transition is viable. Could you please share any guidance, documentation, or recommended strategies for migrating from the jQuery version to React? Thank you for your assistance.

Best regards, Avi

Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)

1 Answer(s)
  • User Avatar
    0
    oguzhanagir created
    Support Team

    Hi @ashgadala

    Thank you for reaching out. Yes, moving from the MVC/jQuery version to the React version is a viable. All ASP.NET Zero UI versions are built on the same server side solution. What changes is the presentation layer, not your business code or your database. Below is what carries over, what needs to be rebuilt, and the approach we recommend.

    What stays the same

    For a given ASP.NET Zero version, the MVC, Angular and React editions share the same back end:

    • Domain layer (Core, Core.Shared): entities, domain services, business rules
    • Application layer (Application, Application.Shared): application services, DTOs, permissions, validation
    • Data layer (EntityFrameworkCore): DbContext, repositories, migrations, and your existing database. Switching the UI needs no schema change or data migration.
    • Server side infrastructure: localization files, settings, features, multi tenancy, background jobs and notifications are all reused as they are.

    If your business logic lives in application and domain services, most of what you have built carries over unchanged.

    What changes

    • Hosting model: The MVC version is a single application (Web.Mvc) that renders Razor views and uses cookie authentication. The React version is a single page application that calls a separate API host (Web.Host) using token based authentication. You will deploy two parts (the React build and Web.Host) instead of one.
    • Views and scripts: Razor views and their jQuery scripts are rewritten as React components. The React app calls the back end through generated TypeScript service proxies instead of the dynamic abp.services.app.* JavaScript proxies.
    • UI stack: React with TypeScript, Ant Design components and Redux Toolkit, using the same Metronic 8 theme for the layout, so the application will look familiar to your users.
    • Third party jQuery plugins you added will need React equivalents. Ant Design covers most needs: tables, forms, date pickers, selects and uploads.

    Recommended approach

    1. Upgrade first, then migrate. If your project is on an older ASP.NET Zero version, first upgrade it to the latest version, which includes the React UI, as a separate step. Combining a version upgrade with a UI migration makes problems much harder to isolate.

    2. Download the React edition of the same version. Download the React edition from the download page with the same company and project name. Because the backend projects are identical, comparing them with your solution shows exactly which parts are your own customizations.

    3. List your customizations. They usually fall into these groups:

      • Backend code (entities, application services, migrations): reused as is
      • Business logic inside MVC controllers: move it into application services so it is available as an API
      • Pages you added: need to be built in React
      • Changes to built in pages (users, roles, tenants, settings, etc.): these pages already exist in React, so only your changes need to be reapplied
      • Theme and styling changes, custom JavaScript components

      This list gives you a realistic effort estimate before you commit.

    4. Move your back end over. Add the Web.Host project to your solution, or move your backend projects into the React solution, and connect it to your existing database. All your application services are then available as REST APIs, which you can check in Swagger.

    5. Rebuild the UI page by page.

      • If you created entities with ASP.NET Zero Power Tools, you are in luck: Power Tools supports React. You can regenerate the React CRUD pages from the entity definitions it saved in your solution, which saves a lot of time.
      • For custom pages, start with a proof of concept of one or two typical screens, for example a simple CRUD page and your most complex screen. This helps your team learn the patterns and makes the estimate for the rest much more accurate.
    6. Optionally, run both UIs side by side during the transition. Both applications use the same back end and database, so you can keep the MVC application in production while you build and roll out the React application module by module. Retire the MVC application once everything has moved. During this period users sign in to each application separately.

    7. Review your configuration before going live. Check the client and server root addresses, the allowed CORS origins, and the URLs used in system emails (password reset, email confirmation). These should now point to the React application.

    How much effort to expect

    The effort depends mostly on how many custom pages you have and how complex they are. Backend work is usually small. A project made mostly of Power Tools generated CRUD pages can be migrated fairly quickly. Many highly interactive custom jQuery screens will take more frontend work. Your team will need React and TypeScript experience, and the proof of concept is a good time to build it.

    Best regards

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)