{"data":{"markdownRemark":{"html":"<p><span style=\"text-align: center; display: block;\">Part of <a href=\"/gatsby-v2\">a series on Gatsby v2</a></span></p>\n<p>You're familiar with Gatsby. You realise there's much awesomeness in v2. You want some of that now. You <strong>need</strong> it now.</p>\n<blockquote>\n<p><strong>tl;dr</strong> - Install <code class=\"language-text\">react</code>, <code class=\"language-text\">react-dom</code>, <code class=\"language-text\">gatsby@next</code> and probably <code class=\"language-text\">react-helmet</code>.</p>\n</blockquote>\n<h2>What's in v2?</h2>\n<p>Why is v2 awesome? A handful of reasons. You can check out the <a href=\"https://github.com/gatsbyjs/gatsby/projects/2\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">v2 project</a> for a good overview. A few of our personal highlights include:</p>\n<ul>\n<li>Load data via JSON outside of webpack</li>\n<li>No more layouts, GraphQL queries in all components</li>\n<li>Modern builds for modern browsers</li>\n</ul>\n<h3>Better data loading</h3>\n<p>You've read about why <a href=\"/can-gatsby-handle-large-sites\">Gatsby chokes on large sites</a>? Now's a good time. We'll wait. You can come right back via the \"back\" button.</p>\n<p>Gatsby needs a list of every page on your site. Then where the data for that page can be found. It's a static file. The file name includes a <a href=\"/what-is-cache-busting-or-content-hashing\">cache busting hash</a>. We need to know the filename. There's no way to guess. This list has 1 entry for every page. 100k pages means 100k entries.</p>\n<p>In Gatsby v1 the entire list is put into the HTML of <strong>every page</strong>. That means if you have a lot of pages, your HTML files will be huge. It's a problem. It makes Gatsby v1 impractical for sites with more than ~1k pages.</p>\n<p>This is fixed in Gatsby v2. First, the list is much, much smaller. Second, it's no longer part of the HTML. It's loaded <em>after</em> the page has rendered. These changes are <strong>huge</strong>. Gatsby v2 will easily support sites with 5k pages. Maybe even 50k or 100k pages.</p>\n<h3>GraphQL everywhere</h3>\n<p>You know that Gatsby only allows GraphQL queries in two places. In layouts and page components. Layouts are disappearing in v2. You can use GraphQL in any component instead.</p>\n<blockquote>\n<p>This is currently a work in progress. It might change by the final release of v2.</p>\n</blockquote>\n<p>No more layouts. So what now? Now you wrap your components in other components. You can create any kind of \"layout\" hierarchy you want. Awesome. How do we get data into those components? Via the new <code class=\"language-text\">StaticQuery</code>.</p>\n<p>What is <code class=\"language-text\">StaticQuery</code>? It's a new component. It's a bit like <code class=\"language-text\">Provider</code> from redux. You give it a GraphQL query. It fetches that data and delivers it to your component.</p>\n<p>How does it work? That's still not finalised. But checkout <a href=\"https://github.com/gatsbyjs/rfcs/pull/2\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Gatsby's first RFC for more details</a>.</p>\n<h3>Modern builds</h3>\n<p>You write modern javascript. Then babel and webpack \"transpile\" it. Now your sites work in old browsers. Wooho!</p>\n<p>The transpiled code is bigger. It includes lots of \"polyfills\". These are special helpers for old browsers which don't have some modern features.</p>\n<p>Modern javascript today. Awesome. But now all modern browsers are also fetching polyfills. They don't need them. They could download smaller bits of code instead.</p>\n<p>That's the goal of modern builds. Give modern browsers a smaller build. Keep the bigger builds for old browsers.</p>\n<p>Another performance optimisation from Gatsby. This is just an idea right now. It hasn't been built yet. You can read the <a href=\"https://github.com/gatsbyjs/gatsby/issues/2114\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">discussion about it here</a>.</p>\n<h2>Tech changes</h2>\n<p>So v2 will be awesome. You want it <em>now</em>. Great. But there's no migration guide yet. Darn.</p>\n<p>Here's a short list of some of the bigger changes from v1 to v2. This list is definitely not exhaustive. v2 is constantly evolving. This list will get you started until the v2 migration guide comes out.</p>\n<ul>\n<li>React &#x26; React Dom are peer dependencies now</li>\n<li><code class=\"language-text\">pathContext</code> is now <code class=\"language-text\">pageContext</code></li>\n<li>PostCSS / <code class=\"language-text\">.scss</code> has changed</li>\n</ul>\n<h2>Try v2 now</h2>\n<p>You're convinced. You want to try it now. Awesome.</p>\n<p>First, do this in a branch. It might not work.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">git checkout -b gatsby-v2</code></pre></div>\n<h3>Install</h3>\n<p>First, install the <code class=\"language-text\">react</code> and <code class=\"language-text\">react-dom</code>. They are now peer dependencies. They must go into your <code class=\"language-text\">package.json</code>.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">yarn add react react-dom</code></pre></div>\n<p>Great. Are you using helmet? Probably. If you are, install it. Same as above.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">yarn add react-helmet</code></pre></div>\n<p>Now install Gatsby v2. It's easy.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">yarn add gatsby@next</code></pre></div>\n<p>You've installed Gatsby v2. Congratulations. Unfortunately, it probably doesn't work yet. Try anyway, just for fun!</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">gatsby develop</code></pre></div>\n<p>Errors? You probably need to update some other Gatsby packges. It's hard to know exactly which ones. Are you using the filesystem source plugin? Probably. Update it.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">yarn add gatsby-source-filesystem@next</code></pre></div>\n<h2>Errors</h2>\n<p>You might have errors at this point. Try to figure out which package they're coming from. Try upgrading that package.</p>\n<blockquote>\n<p><strong>Be careful</strong>. Some packages have <code class=\"language-text\">@next</code> versions which are actually old. You can check on the \"Versions\" tab on npm. For example <a href=\"https://www.npmjs.com/package/gatsby-plugin-react-helmet\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">gatsby-plugin-react-helmet</a> today (11 Apr 2018). The <code class=\"language-text\">latest</code> tag is version <code class=\"language-text\">2.0.10</code>. While the <code class=\"language-text\">next</code> tag is <code class=\"language-text\">2.0.6-2</code> which is 10 days older.</p>\n</blockquote>\n<p>This process might take a little trial and error. It's worth it. Remember to make frequent git commits!</p>\n<h2>PostCSS / SaSS</h2>\n<p>There's something new about PostCSS in v2. We haven't fully figured it out. It's not yet documented. We had success by removing the <code class=\"language-text\">gatsby-plugin-postcss-sass</code> package and instead using the <code class=\"language-text\">gatsby-plugin-sass</code> package.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">yarn remove gatsby-plugin-postcss-sass\nyarn add gatsby-plugin-sass@next</code></pre></div>\n<blockquote>\n<p><strong>Warning:</strong> <a href=\"https://www.npmjs.com/package/gatsby-plugin-postcss-sass?activeTab=versions\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">gatsby-plugin-sass</a> is an example of a plugin whose <code class=\"language-text\">@next</code> tag is out of date.</p>\n</blockquote>\n<h2>Help</h2>\n<p>You're messing with advanced level Gatsby fu here. You might have issues. Google is your friend. Check <a href=\"http://stackoverflow.com/questions/tagged/gatsby\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">StackOverflow</a>. Join the #gatsby channel on <a href=\"https://discord.gg/0ZcbPKXt5bVoxkfV\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Reactiflux Discord</a> (Discord is a bit like slack).</p>\n<p>But most of all. Persevere. Good luck.</p>","excerpt":"Part of  a series on Gatsby v2 You're familiar with Gatsby. You realise there's much awesomeness in v2. You want some of that now. You  need…","timeToRead":5,"frontmatter":{"date":"April 10, 2018","path":"/getting-started-with-gatsby-v2","title":"Getting started with Gatsby v2"}},"relatedPosts":{"edges":[{"node":{"id":"88e68246-cc05-58c4-9cb0-9fa48bc65259","frontmatter":{"title":"Gatsby v2 refactoring cheat sheet","path":"/gatsby-v2-refactoring-cheat-sheet","tags":["v2","cheat sheet"]}}},{"node":{"id":"c8ef7f7d-dffc-5aae-b6a0-0084762b39f0","frontmatter":{"title":"Gatsby v2","path":"/gatsby-v2","tags":["v2","beta"]}}},{"node":{"id":"43eb2d0b-dabd-5c3d-8f96-41eeffd1c003","frontmatter":{"title":"How do layouts work in Gatsby v2","path":"/how-do-layouts-work-in-gatsby-v2","tags":["v2"]}}},{"node":{"id":"53048efa-8e60-5988-8f54-73bf441a1ab2","frontmatter":{"title":"Should I rebuild my site for Gatsby v2?","path":"/should-i-rebuild-my-site-for-gatsby-v2","tags":["v2"]}}},{"node":{"id":"36c6d2e1-eff2-5062-aee4-518ccb6f4ea8","frontmatter":{"title":"StaticQuery in Gatsby v2","path":"/staticquery-in-gatsby-v2","tags":["v2"]}}},{"node":{"id":"3a89bcb1-591a-5b78-bb39-6a8488d0ce69","frontmatter":{"title":"What's new in Gatsby v2","path":"/whats-new-in-gatsby-v2","tags":["v2","beta"]}}},{"node":{"id":"9a16f7fc-6fa5-5328-816c-35542c1c38ec","frontmatter":{"title":"When should I upgrade to Gatsby v2?","path":"/when-should-i-upgrade-to-gatsby-v2","tags":["v2"]}}},{"node":{"id":"979a29c5-06ed-5582-b0be-4c37f26b65d4","frontmatter":{"title":"Enable absolute imports for Gatsby v2","path":"/enable-absolute-imports-for-gatsby-v2","tags":["v2"]}}},{"node":{"id":"5eb98a7e-3fd2-5edf-a9f8-44f5e25da39d","frontmatter":{"title":"GatsbyJS source plugin for eventbrite.com","path":"/gatsby-source-eventbrite","tags":["v2","source","eventbrite"]}}},{"node":{"id":"374bf18f-0f86-54c8-bdb1-f051527d8210","frontmatter":{"title":"WordPress starter for GatsbyJS","path":"/gatsby-starter-wordpress","tags":["v2","starter","wordpress"]}}},{"node":{"id":"737d2352-faae-5e91-b298-07399aaf3b1c","frontmatter":{"title":"Starter project for GatsbyJS","path":"/gatsby-central-starter","tags":["v2","starter"]}}}]},"allCommentsJson":{"edges":[{"node":{"id":"5ef26261-6645-5529-b649-2cf2d56ff251","name":"skube","date":1526127923,"fields":{"messageHtml":"<p>So if <code>gatsby-plugin-sass</code> is an example of a plugin whose @next tag is out of date, should one just:\n<code>yarn add gatsby-plugin-sass</code> (instead of appending <code>@next</code>)?</p>"}}}]},"allRatingsJson":{"totalCount":1,"edges":[{"node":{"id":"98c1f194-5e96-5ca1-9684-30b7e4459e35","rating":"5"}}]}},"pageContext":{"tags":["v2"]}}