5

A Review of UltraJS, Mixing React and Deno in a Single Framework

 1 year ago
source link: https://blog.bitsrc.io/a-review-of-ultrajs-mixing-react-and-deno-in-a-single-framework-8e4dd41ea076
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

What is UltraJS?

UltraJS is a web framework that much like Next, provides a back-end for your React front-end. Let me be more specific: it provides a Deno back-end for your React front-end.

And that is one of the main things that differentiate Ultra from others like Next or Remix, which work with Node.js and build on top of it.

While that distinction might sound minor, the set of features that the UltraJS framework provides thanks to it are major.

Essentially, this framework is taking advantage of the latest features JavaScript has to offer, with a positive impact on the dev workflow, because it removes the need for tools like a TS compiler, bundlers and other “archaic” tools that are not really needed anymore.

So let’s take a closer look at these modern features that UltraJS tries to shine a bright light into.

The native TypeScript support for the back-end

The first obvious improvement that we get out of the box by using UltraJS, is that Deno has native support for TypeScript.

Of course, this is an improvement if you’re actually using TypeScript in all your projects. But let’s be honest, lately, most modern frameworks will suggest you do.

And that means the TypeScript compiler and all the setup required to run it with our bundler of choice go out the window.

Of course, when you’re creating the project, you’re given the choice to go with TS or plain JS, so don’t worry, if TypeScript is not your thing, you can still enjoy UltraJS.

There is no bundling with UltraJS

This one might sound a bit controversial, but UltraJS is completely and utterly against bundling, and for a good reason!

Since 2015 JavaScript has officially defined a module system enabling browsers (and other runtimes as well) to import JS modules using JavaScript (instead of using the script tag).

Until 2015, there was no official way and different runtimes had their own way, like Node with the CommonJS standard.

But we’re living in 2022 now, and in these 7 years it’s hard to believe that most frameworks are still relying on bundlers to simplify the loading of JS code into the client.

But not UltraJS, no sir, this modern framework is pushing the state of the art into your project, whether you like it or not!

Of course, Deno is natively supporting ES modules since day one, so the back-end is automatically up-to-date in regards to the standards.

All of that is to say that UltraJS is completely against bundlers and that translates into yet another tool that gets removed from your dev workflow. And let’s be honest, bundlers are usually one of the major steps in the build process, so we’re not only making things easier to maintain, we’re shaving off several seconds (if not more!) from the build process.

I know what you’re saying though, ES modules might be the standard, but you hate importing URLs and that becomes hard to maintain.

Worry not my friend, lucky for you, both UltraJS and Deno also support ImportMap!

Support for ImportMaps is native

Import maps allow you to define keywords that represent whole URLs, so instead of doing:

You can have a mapping from “fmt” to “https://deno.land/[email protected]/fmt”, so you can then do:

Which is, let’s be honest, a lot easier to do, especially if we’re importing the same module from multiple files.

All you have to do to take advantage of this amazing feature, is to define an “importMap” key inside the deno.json file in the root of your UltraJS project.

Of course, that step is already done for you if you’re using the provided generator, so just chill and open the importMap.json file if you need to add more dependencies.

Ability to provide a mixed-rendering environment

While not directly a benefit from having the latest technologies, UltraJS allows you to define the way you render each route. In practice, you can have your static pages rendered in the server, avoiding any JS from being delivered to the client.

And of course, your more dynamic routes can be served normally.

While this is not exactly the “Islands of interactivity” pattern that other frameworks like Fresh provide, it’s a really flexible way of dealing with rendering.

And if you listen to the podcast episode, you’ll hear Omar saying that they’re actually testing the islands pattern in a separate branch, so it’s only time we get there as well.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK