npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@thoughtbot/superglue

v0.53.2

Published

Use a vanilla Rails with React and Redux

Downloads

424

Readme

Superglue

Use classic Rails to build rich React Redux applications with NO APIs and NO client-side routing.

Build Status

Superglue makes React and Redux as productive as Hotwire, Turbo and Stimulus. Its inspired by Turbolinks and designed to feel like a natural extension of Rails. Enjoy the benefits of Redux state management and React components without giving up the productivity of Rails form helpers, UJS, tag helpers, flash, cookie auth, and more.

Caution

This project is in its early phases of development. Its interface, behavior, and name are likely to change drastically before a major version release.

No APIs

Instead of APIs, Superglue leans on Rail's ability to respond to different mime types on the same route. In a Superglue application, if you direct your browser to /dashboard.html, you would see the HTML version of the content, and if you went to /dashboard.json you would see the JSON version of the exact same content down to the footer.

The end result would be something like this:

No Apis

Powered by Classic Rails

Superglue leans on Rails. Features like the flash, cookie auth, and URL helpers continue to be useful. Here's a look at the directory structure of a typical Rails application with Superglue.

app/
|-- controllers/
|-- views/
|   |-- dashboard/
|   |   |-- index.js # The React page component
|   |   |-- index.json.props # The json for the page component
|   |   |-- index.html.erb

PropsTemplate

Powering the JSON responses is PropsTemplate, a digable JSON templating DSL inspired by JBuilder. With PropsTemplate you can specify a path of the node you want, and PropsTemplate will walk the tree to it, skipping the execution of nodes that don't match the keypath.

No Apis

All together now!

Superglue comes with batteries that bring all the above concepts together to make building popular SPA features easy, painless, and productive.

SPA Navigation

A popular ask of SPAs is page-to-page navigation without reloading. This is easily done with Superglue's own UJS attributes inspired by Turbolinks:

  <a href='/posts' data-sg-visit />

The above will request for /posts with an accept of application/json, and when the client receives the response, swap out the current component for the component the response asks for, and pushState on history.

Easy Partial updates

Some features rely on updating some parts of the existing page. Imagine implementing type-ahead search. In traditional applications, you may need a new controller, routes, a discussion over versioning, JSON serializer, plenty of new JS code, etc.

haircuts

With Superglue, this can be done with a simple onChange

const onChange = (e) => (
  remote(`/dashboard?qry=${e.target.value}&props_at=data.header.search`)}
)

?> remote and visit is a thunk passed to every page component.

With props_at, the above will make a request to /dashboard?qry=haircut, dig your template for the data.header.search node, return it in the response, and immutably graft it in the exact same path on the redux store before finally letting React re-render.

For more on what you can do, check out our documentation.

Server-Side Rendering

Server-Side Rendering is supported via Humid. See the documentation for server-side rendering.

Documentation

Documentation is hosted on Github pages.

Contributing

Thank you, contributors!

Special Thanks

Thanks to jbuilder, scour, turbolinks3, turbograft, turbostreamer