<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jon Ruddell</title>
    <description>The latest articles on DEV Community by Jon Ruddell (@ruddell).</description>
    <link>https://dev.to/ruddell</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F576723%2Fa855381c-3d1f-4615-aa2d-4c410bdad7e7.jpeg</url>
      <title>DEV Community: Jon Ruddell</title>
      <link>https://dev.to/ruddell</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ruddell"/>
    <language>en</language>
    <item>
      <title>JHipster React Native Demo</title>
      <dc:creator>Jon Ruddell</dc:creator>
      <pubDate>Fri, 12 Feb 2021 13:36:24 +0000</pubDate>
      <link>https://dev.to/ruddell/jhipster-react-native-demo-1c54</link>
      <guid>https://dev.to/ruddell/jhipster-react-native-demo-1c54</guid>
      <description>&lt;p&gt;&lt;a href="https://github.com/ruddell/generator-jhipster-react-native" rel="noopener noreferrer"&gt;JHipster React Native&lt;/a&gt; is now available as a &lt;a href="https://www.jhipster.tech/modules/creating-a-blueprint/" rel="noopener noreferrer"&gt;JHipster Blueprint&lt;/a&gt;.  Previously known as &lt;code&gt;ignite-jhipster&lt;/code&gt;, the latest version brings many changes and improvements to the developer experience.  With full Expo support (including Web and PWAs), building and deploying the application is easier than ever. For a full changelog, &lt;a href="https://github.com/ruddell/generator-jhipster-react-native/releases/tag/v4.0.0" rel="noopener noreferrer"&gt;see the Github release&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In this demo, we will generate a React Native application. Next, we will launch the React Native app locally on iOS, Android, and Web. To finish up, we will build and deploy the applications, and demonstrate over-the-air updates.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=zQMg1E7meHw" rel="noopener noreferrer"&gt;This blog post is also available in a short 6-minute video format.&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Environment Setup&lt;/li&gt;
&lt;li&gt;Generating the React Native Client&lt;/li&gt;
&lt;li&gt;App Config&lt;/li&gt;
&lt;li&gt;Running the App&lt;/li&gt;
&lt;li&gt;Building and Deploying&lt;/li&gt;
&lt;li&gt;Updating Over the Air&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Environment Setup &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Make sure to have an LTS version of NodeJS, then install the JHipster React Native Blueprint and Expo CLI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i -g generator-jhipster-react-native expo-cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Also make sure to register an Expo account at &lt;a href="https://expo.io/signup" rel="noopener noreferrer"&gt;https://expo.io/signup&lt;/a&gt; if you do not already have one.&lt;/p&gt;

&lt;p&gt;In this demo, we will be using the &lt;code&gt;rnhipster&lt;/code&gt; command, which functions similarly to &lt;code&gt;jhipster --blueprints react-native&lt;/code&gt;. The key difference is &lt;code&gt;rnhipster&lt;/code&gt; uses its own version of JHipster rather than the globally installed version, preventing version mismatches. This allows developers with older JHipster versions such as v6 to use the latest blueprint improvements in JHipster v7.&lt;/p&gt;

&lt;h2&gt;
  
  
  Generate the React Native Client &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Because the React Native blueprint is designed to communicate with a JHipster backend, we'll use an existing application.  We want to use the entities and config from that application to generate our React Native app.  &lt;/p&gt;

&lt;p&gt;The repository for the demo backend is located on Github at &lt;a href="https://github.com/ruddell/jhipster-sample-app-react-native-backend.git" rel="noopener noreferrer"&gt;ruddell/jhipster-sample-app-react-native-backend&lt;/a&gt; and on Heroku at &lt;a href="https://jh-sample-app-react-native-api.herokuapp.com/" rel="noopener noreferrer"&gt;https://jh-sample-app-react-native-api.herokuapp.com/&lt;/a&gt;.  To get the config and entities, we will be using &lt;a href="(https://www.jhipster.tech/jdl/)"&gt;JDL&lt;/a&gt;, a JHipster-specific domain language to describe applications and entities.  The backend JDL can be &lt;a href="https://github.com/ruddell/jhipster-sample-app-react-native-backend/blob/main/jhipster.jdl" rel="noopener noreferrer"&gt;viewed here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Make a new directory for generating the client and import the JDL.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; ../client &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd&lt;/span&gt; ../client
rnhipster jdl https://raw.githubusercontent.com/ruddell/jhipster-sample-app-react-native-backend/main/jhipster.jdl
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Enter a name for the application, enable E2E Detox Tests if desired, and wait for &lt;code&gt;npm install&lt;/code&gt; to finish.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip:&lt;/strong&gt; If you prefer not to use JDL, run &lt;code&gt;rnjhipster&lt;/code&gt; to use the prompts.  Specify the local path to the backend folder and pass the &lt;code&gt;--with-entities&lt;/code&gt; flag to also generate the backend entities.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fqi624ofse2uzq3irnt3d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fqi624ofse2uzq3irnt3d.png" alt="JHipster React Native Banner"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  App Config &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;The API URL is configured in &lt;code&gt;app/config/app-config.js&lt;/code&gt;.  When deploying the app, whether to an App Store or a CDN, it is required to set the &lt;code&gt;apiUrl&lt;/code&gt; to a deployed URL of the backend.&lt;/p&gt;

&lt;p&gt;For this demo, set the &lt;code&gt;apiUrl&lt;/code&gt; to &lt;code&gt;https://jh-sample-app-react-native-api.herokuapp.com/&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;: If you are using OAuth 2.0 for the authentication type, &lt;a href="https://github.com/ruddell/generator-jhipster-react-native/blob/main/docs/oauth2-oidc.md" rel="noopener noreferrer"&gt;see the docs for a guide to Okta and Keycloak configuration.&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Running the App &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;To start the app, run &lt;code&gt;npm start&lt;/code&gt; in the &lt;code&gt;client&lt;/code&gt; directory.  &lt;/p&gt;

&lt;p&gt;There are multiple ways to launch the application directly on a specific platform:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Running On&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Command&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;On Device&lt;/td&gt;
&lt;td&gt;Scan the QR Code with your device&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Web Browser&lt;/td&gt;
&lt;td&gt;&lt;code&gt;npm start -- --web&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;iOS Simulator&lt;/td&gt;
&lt;td&gt;&lt;code&gt;npm start -- --ios&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Android Simulator&lt;/td&gt;
&lt;td&gt;&lt;code&gt;npm start -- --android&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Once the packager is started, you can also launch other platforms.  Press &lt;code&gt;w&lt;/code&gt; for web, &lt;code&gt;i&lt;/code&gt; for iOS, or &lt;code&gt;a&lt;/code&gt; for Android.  &lt;/p&gt;

&lt;p&gt;For iOS and Android Simulator setup, follow the platform-specific instructions for &lt;a href="https://docs.expo.io/workflow/android-studio-emulator/" rel="noopener noreferrer"&gt;Android&lt;/a&gt; and &lt;a href="https://docs.expo.io/workflow/ios-simulator/" rel="noopener noreferrer"&gt;iOS&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F935edefrpnz8ki0h4cte.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F935edefrpnz8ki0h4cte.png" alt="Logged In to the Apps"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Building and Deploying &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Building Web
&lt;/h3&gt;

&lt;p&gt;Run &lt;code&gt;npm run build:web&lt;/code&gt; to build a production deployment of the web client in &lt;code&gt;web-build&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip:&lt;/strong&gt; If you want to enable the PWA, set &lt;code&gt;offline: true&lt;/code&gt; in &lt;code&gt;webpack.config.js&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Deploying Web
&lt;/h3&gt;

&lt;p&gt;Once the web client is built, you can preview it with &lt;code&gt;npx serve web-build&lt;/code&gt;.  If everything looks good, upload the &lt;code&gt;web-build&lt;/code&gt; folder to a static site host or CDN of your choice.&lt;/p&gt;

&lt;h3&gt;
  
  
  Building iOS and Android
&lt;/h3&gt;

&lt;p&gt;You will only need to submit a new build of the app to the App Store for review when you update the Expo SDK in your project.  Otherwise no native code changes, so the Javascript bundle can be updated over-the-air without going through the review processes again.&lt;/p&gt;

&lt;p&gt;iOS and Android apps are built through the &lt;code&gt;expo build&lt;/code&gt; command.  The actual compilation of the app happens in the cloud on Expo's build servers, then the packaged application is available for download.  The build process does take several minutes, but you rarely need to update the Expo SDK.&lt;/p&gt;

&lt;p&gt;For more information on &lt;code&gt;expo build&lt;/code&gt;, see the Expo docs on &lt;a href="https://docs.expo.io/distribution/building-standalone-apps/" rel="noopener noreferrer"&gt;Building Standalone Apps&lt;/a&gt;. &lt;/p&gt;

&lt;h4&gt;
  
  
  iOS
&lt;/h4&gt;

&lt;p&gt;To build your iOS app, run &lt;code&gt;npm run build:ios&lt;/code&gt;. Choose an iOS bundle identifier, then choose either &lt;code&gt;archive&lt;/code&gt; or &lt;code&gt;simulator&lt;/code&gt;.  &lt;/p&gt;

&lt;p&gt;An Apple App Store developer account is required for the &lt;code&gt;archive&lt;/code&gt; option, which is later uploaded to your iOS App Store builds.  You can start a build for the Simulator without a developer account.&lt;/p&gt;

&lt;h4&gt;
  
  
  Android
&lt;/h4&gt;

&lt;p&gt;To build your iOS app, run &lt;code&gt;npm run build:ios&lt;/code&gt;. Choose an Android package name, then choose either &lt;code&gt;apk&lt;/code&gt; or &lt;code&gt;aab&lt;/code&gt;.  &lt;/p&gt;

&lt;p&gt;An &lt;code&gt;apk&lt;/code&gt; builds an application that you can directly install on any device.  An &lt;code&gt;aab&lt;/code&gt; builds an optimized build of your app for deployment through the Google Play Store.&lt;/p&gt;

&lt;h3&gt;
  
  
  Deploying iOS and Android
&lt;/h3&gt;

&lt;p&gt;You can deploy your apps built in the previous step to the App Stores with &lt;code&gt;expo upload:ios&lt;/code&gt; and &lt;code&gt;expo upload:android&lt;/code&gt;. You will need a developer account for both App Stores to submit an app for listing.&lt;/p&gt;

&lt;p&gt;For information on &lt;code&gt;expo upload&lt;/code&gt;, see the Expo docs on &lt;a href="https://docs.expo.io/distribution/uploading-apps/" rel="noopener noreferrer"&gt;Uploading Apps to the Apple App Store and Google Play&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Updating Over the Air &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Once your apps have been deployed to the App Stores, you can release new updates with the &lt;code&gt;expo publish&lt;/code&gt; command.  The next time a user loads the application, the latest client will download and prepare itself.  On the second launch, the new client is displayed with any updates.&lt;/p&gt;

&lt;p&gt;Web updates are not currently supported, so you will still need to deploy those changes manually.&lt;/p&gt;

&lt;p&gt;For information on OTA Updates, see the Expo docs on &lt;a href="https://docs.expo.io/guides/configuring-ota-updates/" rel="noopener noreferrer"&gt;Configuring OTA Updates&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;In this post, we demonstrated how to generate the app, make changes, configure a backend, build native/web apps, release over-the-air updates, and run E2E tests.&lt;/p&gt;

&lt;p&gt;Any questions, comments, improvements, issues, and pull requests are welcome over at the &lt;a href="https://github.com/ruddell/generator-jhipster-react-native/" rel="noopener noreferrer"&gt;JHipster React Native Github page&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>jhipster</category>
      <category>reactnative</category>
      <category>expo</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
