Node 18 has been promoted to the long term service (LTS) version, and we’re bringing all the latest tools and goodies to your Gadget apps. Start building next-gen Node apps in Gadget, and get access to any modern tooling that requires Node 18, like LangChain, web streaming, global fetch, and more.
Up until now, all apps using Gadget have run Node 16. New Gadget apps will be created using Node 18 by default, and it will soon be available as an option for existing apps as well. This is a peek at how Gadget will allow you to upgrade other platform packages in the future.
With the switch to Node 18 come some noteworthy additions, so let’s look at how you might use them.
With the addition of global browser APIs like fetch, you can fetch resources from the network without requiring packages like axios or got. The choice between axios, got, or Node fetch is personal, but making a request can be as simple as calling await fetch(url):
Until now, if you were looking to build modern tools or work with AI models, you’ve had to download an entire file, wait for it to be deserialized, and then process it once it’s all completed. This is not only time consuming, with the response delays being passed on to users, but also can be a source of stress on memory because the entire payload needs to be loaded up before it is sent to the recipient. With the Web Streams API introduced in Node 18 you can instead process this data in chunks as a ‘stream’. This, along with the detecting when streams start or finish, and error handling, can be used to build some pretty cool experiences.
If you’ve gotten used to ChatGPT-like experiences where the response is appearing word by word, you already have a sense of what experiences you can build with streaming.
If you’re looking to try building something using the Web Streams API but you’re not sure where to start, we’ve put together an easy-to-follow tutorial to get started with your first build.
Speaking of ChatGPT, upgrading to Node18 will also unlock access to newer packages that aren’t supported by Node 16, such as LangChain. The package has quickly become a staple with AI app developers, making it easier to build applications powered by language models.
Our recent tutorial on how to build a product recommendation chatbot is a great place to start if you want to try your hand at building an AI-powered Shopify app.
As always, if you have questions, reach out to us on our developer Gadget Discord.