<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title type="text">Blog posts by Sam K @ MtE</title><link href="http://world.optimizely.com" /><updated>2021-11-19T13:52:04.0000000Z</updated><id>https://world.optimizely.com/blogs/sam-k--mte/</id> <generator uri="http://world.optimizely.com" version="2.0">Optimizely World</generator> <entry><title>Adding React to an Optimizely UI - Part 2</title><link href="https://dev.to/skmte/adding-react-to-an-optimizely-ui-part-2-n37" /><id>&lt;p&gt;In &lt;a href=&quot;https://dev.to/skmte/adding-react-to-an-optimizely-ui-part-1-31kh&quot;&gt;Part 1 of this series&lt;/a&gt;, I gave a start-to-finish overview of how we at &lt;a href=&quot;https://www.madetoengage.com&quot;&gt;Made to Engage&lt;/a&gt; integrated a React application into an Optimizely ASP.NET MVC website.&lt;/p&gt;

&lt;p&gt;I&#39;d like to delve into several aspects of the process in more detail over the next few parts, starting with the choice of React itself and the specifics of how we actually implemented it, given there were (as there always is with anything front-end...) several options.&lt;/p&gt;

&lt;h2&gt;
  &lt;a href=&quot;#why-a-frontend-framework&quot;&gt;
  &lt;/a&gt;
  Why a Front-End Framework?
&lt;/h2&gt;

&lt;p&gt;JavaScript is easily the most flexible way of implementing a performant, user-centric experience in a browser. Your HTML gives you structure, CSS makes it pretty and JavaScript manipulates it as necessary. &lt;/p&gt;

&lt;p&gt;At some point, the amount of JavaScript code increases and the amount of manipulation required - even with the help of some still very popular libraries... &lt;strong&gt;cough...&lt;small&gt;jQuery&lt;/small&gt;...cough&lt;/strong&gt; - reaches the point of being unmanageable and unsustainable. FE frameworks have, in recent years, really risen to address these limitations. &lt;/p&gt;

&lt;p&gt;Taking on a project to do exactly what these frameworks are designed to do really meant it was a no-brainer to go with one.&lt;/p&gt;

&lt;h2&gt;
  &lt;a href=&quot;#but-which-one&quot;&gt;
  &lt;/a&gt;
  But which one?
&lt;/h2&gt;

&lt;p&gt;The decision of which front-end framework to build on given a reasonably blank slate is always a challenging one. The stereotype of the front-end development landscape changing every 15 minutes is not entirely undeserved - the choices are, indeed, ever more numerous.&lt;/p&gt;

&lt;p&gt;But the big name players are still &lt;a href=&quot;https://reactjs.org/&quot;&gt;React&lt;/a&gt;, &lt;a href=&quot;https://angular.io/&quot;&gt;Angular&lt;/a&gt; and &lt;a href=&quot;https://vuejs.org/&quot;&gt;Vue&lt;/a&gt;, in my opinion (and I fully confess there was a lot of my opinion in the decision phase here!). Other noteworthy candidates were &lt;a href=&quot;https://nextjs.org/&quot;&gt;Next.JS&lt;/a&gt; and &lt;a href=&quot;https://svelte.dev/&quot;&gt;Svelte&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;However, for reasons including (but not limited to):&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In-house developer experience&lt;/li&gt;
&lt;li&gt;Learning curve&lt;/li&gt;
&lt;li&gt;Community support and documentation&lt;/li&gt;
&lt;li&gt;Training availability&lt;/li&gt;
&lt;li&gt;Package library diversity&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;...we chose React. &lt;/p&gt;

&lt;p&gt;And then we added &lt;a href=&quot;https://www.typescriptlang.org&quot;&gt;TypeScript&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;As I mentioned in Part 1, I&#39;ve been someone who was - despite my years of experience and interest in new development tools - actively resistant to adopting TypeScript. But I&#39;m willing to admit I was mistaken. It has definitely grown on me. &lt;/p&gt;

&lt;p&gt;The supporting tools in IDEs like VS Code are really excellent and the assistance you get when developing actually does help significantly. I can&#39;t see us starting any significant piece of JS development in the future without using TypeScript.&lt;/p&gt;

&lt;p&gt;I have no doubt that:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;perfectly valid arguments could have been made for using a number of other frameworks&lt;/li&gt;
&lt;li&gt;we would have successfully produced a solution using any one of those number of other frameworks&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;But React it would be for us for now.&lt;/p&gt;

&lt;h2&gt;
  &lt;a href=&quot;#integrating-with-net&quot;&gt;
  &lt;/a&gt;
  Integrating with .NET
&lt;/h2&gt;

&lt;p&gt;Since we remain somewhat constrained by a traditional MVC architecture and a UI rendered using Razor views, we needed a way to integrate the React app into the site.&lt;/p&gt;

&lt;p&gt;One potential option would have been to use &lt;a href=&quot;https://reactjs.net/&quot;&gt;ReactJS.NET&lt;/a&gt; - a platform almost specifically built to do what we were trying to do. But the coupling of Razor and React required by this tool just felt &quot;wrong&quot;, and would have left us inseparably tied to React (&lt;a href=&quot;https://world.optimizely.com/forum/developer-forum/Developer-to-developer/Thread-Container/2020/5/using-reactjs-net-is-dxp/#222699&quot;&gt;a view also expressed by the Optimizely team themselves&lt;/a&gt;). Given our &quot;proof of concept&quot; stage, maintaining the ability to swap out one framework for another one in the (unlikely-but-you-just-never-know) event of reaching an insurmountable road block was important.&lt;/p&gt;

&lt;h2&gt;
  &lt;a href=&quot;#-raw-createreactapp-endraw-&quot;&gt;
  &lt;/a&gt;
  &lt;code&gt;create-react-app&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;The de-facto standard when starting a new React application is to open a terminal and run &lt;code&gt;npx create-react-app&lt;/code&gt;. Again, we decided against this. Whilst this app does indeed give you absolutely everything you need to create, build and deploy a React application, it includes a bulk load of features that we didn&#39;t expect to need and we weren&#39;t creating a Single Page Application (SPA) - something &lt;code&gt;create-react-app&lt;/code&gt; is very much angled towards.&lt;/p&gt;

&lt;p&gt;Our app was going to be a fully built-by-hand endeavour. Starting with a brand new working folder and &lt;code&gt;npm init&lt;/code&gt; and a &lt;code&gt;src/index.tsx&lt;/code&gt;, off we went.&lt;/p&gt;

</id><updated>2021-11-19T13:52:04.0000000Z</updated><summary type="html">Blog post</summary></entry> <entry><title>Adding React to an Optimizely UI - Part 1</title><link href="https://dev.to/skmte/adding-react-to-an-optimizely-ui-part-1-31kh" /><id>&lt;p&gt;At &lt;a href=&quot;https://www.madetoengage.com&quot;&gt;Made to Engage&lt;/a&gt;, we build solutions on the &lt;a href=&quot;https://www.optimizely.com&quot;&gt;Optimizely Content and Commerce platforms&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;We have a significant number of clients using Optimizely Content up to v11 and we&#39;ve been considering how we might be able to deliver some of the more complex and heavily interactive user journeys our clients need by leveraging modern front-end frameworks. In this post, I want to walk you through how we&#39;ve recently architected the introduction of React to part of the site for one of our largest e-commerce partners.&lt;/p&gt;

&lt;p&gt;This is the first part of a series looking at how we approached this challenge as an organization in which I&#39;ll summarize the technologies and solutions. In subsequent parts, I&#39;ll break down some of the key aspects in more technical detail - keep an eye out for these over the coming weeks.&lt;/p&gt;

&lt;h2&gt;
  &lt;a href=&quot;#whats-the-motivation&quot;&gt;
  &lt;/a&gt;
  What&#39;s the motivation?
&lt;/h2&gt;

&lt;p&gt;Front-end frameworks are obviously becoming huge in terms of developing web solutions and user interfaces. With Optimizely Cloud being built on a server-based ASP.NET MVC architecture, there&#39;s a challenge to leveraging some JavaScript tools.&lt;/p&gt;

&lt;p&gt;But user expectations are growing ever higher. Performance, personalization and quality experiences are essential for any site and significant improvements in these areas can have huge impact on conversions in an e-commerce context. As an agency, we have the design and UX expertise to know what works in these areas and this exercise was about how to implement those ideas technically.&lt;/p&gt;

&lt;h2&gt;
  &lt;a href=&quot;#what-would-we-need&quot;&gt;
  &lt;/a&gt;
  What would we need?
&lt;/h2&gt;

&lt;p&gt;So how would we inject a React app with all its dependencies on CMS content and configuration into the existing site and have it render on-screen? &lt;/p&gt;

&lt;p&gt;We would need:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The React application itself&lt;/li&gt;
&lt;li&gt;A placeholder within the Razor views of the MVC site in which to inject the React code&lt;/li&gt;
&lt;li&gt;A mechanism to provide the required data to the React app&lt;/li&gt;
&lt;li&gt;Support for server-side rendering (SSR)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I&#39;ll go into the thought processes (e.g., why React?) and structure of these individual items in further posts throughout this series.&lt;/p&gt;

&lt;h2&gt;
  &lt;a href=&quot;#the-react-app&quot;&gt;
  &lt;/a&gt;
  The React App
&lt;/h2&gt;

&lt;p&gt;Items 1 and 2 were intrinsically tied. We had to have a React app and then confirm that we could get it to render in the context of using Razor views. On the surface, this seems pretty trivial - you just need some JS files declared as a bundle and included in your Razor! But this was key to deciding if the approach would work long-term, so we had to prove it as a concept.&lt;/p&gt;

&lt;p&gt;We also had to decide whether or not to use TypeScript. With 20+ years of writing JavaScript under my belt, I&#39;ve been a slightly hesitant adopter of TypeScript, but it honestly feels like starting any significant JS development project nowadays without it is churlish. TypeScript it was - more on that in a later post.&lt;/p&gt;

&lt;p&gt;We created a very simple app initially to ensure it could be embedded into the site as we wanted. Since &quot;create-react-app&quot; generally focuses on SPAs and includes a lot of features we didn&#39;t expect to need, we decided against it but instead hand-crafted the packages and files we needed.&lt;/p&gt;

&lt;p&gt;For context, our first &lt;code&gt;index.tsx&lt;/code&gt; app looked something like this:&lt;br /&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight jsx&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;React&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;ReactDOM&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;react-dom&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;App&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;./app&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;ReactDOM&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;App&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;/&amp;gt;,&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;getElementById&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;react-app&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using Webpack, we built this to an existing folder within the .NET web application to make it easily referenceable using the following partial config:&lt;br /&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight javascript&quot;&gt;&lt;code&gt;&lt;span class=&quot;nx&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;exports&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;env&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;argv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;entry&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;react-app&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;./src/index.tsx&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;[name].js&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;resolve&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;__dirname&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;../static&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;resolve&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;extensions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;.ts&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;.tsx&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;.js&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We quickly reached a point of having a compiled JavaScript file that we could reference in our Optimizely Content site.&lt;/p&gt;

&lt;h2&gt;
  &lt;a href=&quot;#razor-placeholder&quot;&gt;
  &lt;/a&gt;
  Razor Placeholder
&lt;/h2&gt;

&lt;p&gt;The next task was to add something to the Razor views to get the app to appear on screen, leading us to this:&lt;br /&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight html&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;react-app&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
@Html.VersionedJs(&quot;~/static/react-app.js&quot;)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With a quick &lt;code&gt;npm run build&lt;/code&gt; of our React app and a spin-up of the Optimizely MVC site, we browsed to the necessary address. Et voil&#224;! A React app rendered inside an Optimizely view.&lt;/p&gt;

&lt;h2&gt;
  &lt;a href=&quot;#injecting-data-populating-state&quot;&gt;
  &lt;/a&gt;
  Injecting Data (Populating State)
&lt;/h2&gt;

&lt;p&gt;The most important element of making this work was ensuring that the React app had the required data. This would obviously be built and prepared by the back-end C#, but how best to get it into the app? Really, it comes down to one of two options:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Render the data in some way on the page (e.g. hidden field) and consume it within your React start-up.&lt;/li&gt;
&lt;li&gt;Mount the React app and trigger an immediate callback to fetch the data.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The trade offs here are about performance and user perception of speed. We went for the former initially, purely because a lot of the work to build the data was done on page load behind the scenes, so it didn&#39;t really make sense to get a blank, placeholder UI on screen before then re-requesting much of the already built data. We may review that over time as our app grows.&lt;/p&gt;

&lt;p&gt;Using &lt;a href=&quot;https://redux.js.org/&quot;&gt;Redux&lt;/a&gt; for state management (which will be important in the SSR section below), our app instantiation code expanded to look like this:&lt;br /&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight javascript&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;React&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;ReactDOM&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;react-dom&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Provider&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;react-redux&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;App&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;./app&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;initStore&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;./redux/store&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;dataBlob&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;getElementById&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;initial-state&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;HTMLElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;storeData&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;JSON&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;parse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;dataBlob&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;store&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;initStore&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;storeData&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;ReactDOM&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Provider&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;store&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;store&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;App&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/Provider&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  &lt;a href=&quot;#server-side-rendering&quot;&gt;
  &lt;/a&gt;
  Server Side Rendering
&lt;/h2&gt;

&lt;p&gt;Given this React app was being included in a major e-commerce solution with significant SEO foundations already in place, it became clear we would need to implement server-side rendering (SSR) of our React app to maintain those high scores and visibility. This was definitely one of the more interesting aspects of the overall project and will be covered in detail in a later post - it turned into a very expansive aspect, too!&lt;/p&gt;

&lt;h2&gt;
  &lt;a href=&quot;#summary&quot;&gt;
  &lt;/a&gt;
  Summary
&lt;/h2&gt;

&lt;p&gt;So, that&#39;s the overview - a proof of concept idea to include a significant, standalone React element in a long-established ASP.NET MVC application, with state management and SSR to support continued SEO efforts, taken through to a production-quality implementation.&lt;/p&gt;

&lt;p&gt;In the rest of the series, I&#39;ll go into more detail about the different parts of the solution and hopefully be able to share something of how the changes have been received by our client and their customers once released.&lt;/p&gt;

</id><updated>2021-11-05T14:19:37.0000000Z</updated><summary type="html">Blog post</summary></entry></feed>