is it possible to use the gatsby static site generator with reactrb?

140 Views Asked by At

So, I'm basically still pretty new to the whole npm/react.js (let alone react.rb) ecosystem, and I'm wondering if it would be possible to use reactrb with the gatsby static site generator.

I've been attempting to get opal/reactrb support through opal-webpack, but have been running into some issues (see this issue for some backstory https://github.com/cj/opal-webpack/issues/36). Specifically where I got stuck was trying to get it to play nice with bundler.

Is combining reactrb components with gatsby something that's even feasible? I'm hoping the answer is yes.

2

There are 2 best solutions below

0
On

You can fetch data into Gatsby form any kind of source. You need to create a source plugin. The answer from @BarrieH is accurate, but could be slightly misleading.

You cannot query directly from an external GraphQL API into a component. Gatsby works by loading all your data into its own nodes system, then you pull data from those nodes into your components. This is what allows Gatsby to compile your data to static JSON files on disk, pre-fetch data for other pages, and so on.

Here's the relevant docs: https://www.gatsbyjs.org/docs/create-source-plugin/

0
On

Sorry for the very late response. Reactrb has been renamed ruby-hyperloop and yes, you can certainly use it with Gatsby and any static site generator. The Hyperloop website is built with Middleman for example.

The best way to integrate Hyperloop into a static site generator is by using Hyperloop.JS https://github.com/ruby-hyperloop/hyperloop-js which has not server footprint at all.

Please see the Hyperloop website for examples and tutorials: http://ruby-hyperloop.io/