Reviewed: Ways to Wrap a React Website in a Native App
Tags: react, reactnative, webdev
Published: 2023-03-13 08:19:20

React and React Native are the most popular technologies for developing web and mobile applications right now. They are widely adopted by developers and companies alike due to their efficiency, speed, and ability to create high-performance user interfaces.

As a software company specializing in React & React Native, we often get asked how to wrap a React website in a native app or share code between web and mobile apps. It’s a relevant question that many developers and companies face when trying to expand their reach and offer their services on multiple platforms. This article will cover some options for solving this issue and wrapping a React website in a native app.

But why would you want to wrap a React website in a native app and publish it on the app stores? There are several reasons why this might be beneficial for your project.

First, having an app version of your website can improve user experience and engagement. Users can easily access your content or services through a dedicated app on their mobile devices without navigating through a browser. This can result in higher retention rates and increased user satisfaction.

Secondly, publishing your app on the app stores can give you access to a broader audience and increase your brand visibility. App store optimization (ASO) techniques can help you rank higher in search results, making it easier for potential users to discover your app.

Finally, wrapping your React website in a native app using React Native can also improve performance and speed. Native apps have access to device-specific features like push notifications, cameras, GPS, etc., which can enhance the functionality of your app and provide a better user experience.

Wrapping your React website in a native app and publishing it on the app stores can benefit your project. It’s worth considering if you want to expand your reach and engage with more users.

## WebView

This is, by far, the easiest way to achieve the task is to wrap your React website into a [WebView](https://reactnative.dev/docs/custom-webview-android). This component allows you to display web content within your native app, giving users the same experience as if using a browser. Even though the name WebView is used by the [Android](https://developer.android.com/reference/android/webkit/WebView) platform only, often iOS’s implementation, [WKWebView](https://developer.apple.com/documentation/webkit/wkwebview) is also called the same.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0flainlllm3jlza0jd3v.png)

While this is the easiest way, there is a catch. The Apple App Store and the Google Play Store have specific requirements for using WebView on native apps.

According to the [Apple App Store Review Guidelines](https://developer.apple.com/app-store/review/guidelines/), WebViews are acceptable if they adhere to certain guidelines. For example, WebViews must be used to display user-generated content and should not offer a browsing experience within the app. Additionally, if your app is designed to be a hybrid of native and web-based content, it may be acceptable to use WebViews.

On the other hand, the Google Play Store also has specific guidelines for using WebView in native apps. According to their policy, apps that are just a WebView of a website or have only minor changes or enhancements to existing websites are not allowed on the store. However, there are some exceptions when using WebView is acceptable. For example, suppose your app provides additional functionality beyond what is available in a web application, such as offline support or access to device-specific features like camera and GPS. In that case, it may be allowed on the Google Play Store.

Additionally, suppose your app is designed to be an alternative to a web-based platform rather than just displaying the same content as the website. In that case, it may be eligible for distribution on the Google Play Store. In this case, you should ensure that your app meets all other policy requirements and guidelines before submitting it for review.

It’s important to note that both app stores reserve the right to reject any app that does not meet their policies and guidelines. Therefore, before wrapping your React website in a native app using WebView or any other method, thoroughly read and understand their rules and regulations to avoid rejection or removal from the stores.

## React Native

React Native is a popular choice when it comes to developing hybrid apps. It’s an open-source framework created by Facebook that combines the benefits of both React and React Native. It enables developers to build high-performance applications compatible with multiple platforms while providing access to device-specific features like push notifications.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ibp8byvokih9co02ss18.png)


One of the benefits of using React Native to wrap your React website in a native app is that it allows you to create a truly native experience for your users. While WebView displays web content within a native app, React Native makes native components that render on the device’s UI. This means that the app looks and feels like a native application.

Compared to traditional native applications developed in Java or Swift, React Native offers several advantages. First, it enables code sharing between web and mobile apps, saving time and resources during development. Second, it provides access to a vast ecosystem of pre-built components and modules that can be easily integrated into your project.

To wrap your React website in a native app using React Native, you’ll need to create a new React Native project and add your website files to the project.

Using React Native to wrap your React website in a native app can save you from rejection or removal from the stores due to policy violations. While wrapping your React website in a WebView is the easiest way to create a native app, it may not meet the strict requirements of app stores. In contrast, using React Native requires more work but can provide you with a truly native experience and better performance. Moreover, apps developed using React Native are easily accepted by app stores because they use native components rather than WebViews.

## Cordova

Cordova is another possible tool for wrapping react websites in native apps. It’s an open-source mobile application development framework that allows developers to create cross-platform apps using HTML, CSS, and JavaScript. It also provides access to device-specific features like camera, GPS, etc., which can be used to enhance the functionality of your app and provide a better user experience.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/shz2qpy65dnkm70x1bf4.png)

While Cordova used to be a popular tool for hybrid apps, it has been losing popularity recently. One clear signal for this is the latest [StackOverflow Developer Survey 2022](https://survey.stackoverflow.co/2022/#section-most-loved-dreaded-and-wanted-other-frameworks-and-libraries), showing that 75% of developers say they would not use it, given other options.

The main reason for this decline is that as more developers move towards using React Native or similar frameworks, Cordova has fewer resources and support. This makes it challenging for devs to troubleshoot issues or find solutions when working with Cordova.

Overall, while Cordova may still be a viable option for some projects, its declining popularity and limitations compared to other alternatives make it less appealing for many developers looking to wrap their websites in native apps.

## React-Native-Web

Our favorite way of wrapping a react app in a native app here at Lexis Solutions is [the react-native-web](https://github.com/necolas/react-native-web) library by @[necolas](https://github.com/necolas). This library brings the power of React Native Components and APIs to the web. It allows developers to create web applications that are accessible across different devices and input modes while rendering semantic HTML tags. This library allows developers to share code between web and mobile applications, enabling them to create a bridge between the two platforms. You can build iOS, Android, and Web apps with the same codebase.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5qbe4fzkk5wmqz0mysgv.png)

It works by aliasing the `react-native` import to `react-native-web` using your web bundler's (Only Webpack supported) capabilities. This way, while your React Native apps import components and APIs from `react-native`, your web-app imports the React equivalent. You can find the supported features in their detailed documentation.

This is an A+ solution for wrapping a react app in a native app, and we have used it on many production apps in Healthcare, E-Commerce, and Finance.

## Summary

In summary, several options are available for wrapping your React website in a native app, including using WebView, React Native, Cordova, and React-Native-Web. Each option has advantages and disadvantages; the choice ultimately depends on your project’s requirements and your development team’s skills.

If you’re unsure which option is best for your project or need help wrapping your React website in a native app, drop us a line. Our team of experienced developers at Lexis Solutions can provide guidance and support to ensure your idea’s success. Contact us today!

**Bilyal Mestanov — Co-founder at [Lexis Solutions](https://www.lexis.solutions/)**