Home / Blog / Developing a Full Stack Nuxt App with Bolt.new – An AI Experiment
Developing a Full Stack Nuxt App with Bolt.new – An AI Experiment

Developing a Full Stack Nuxt App with Bolt.new – An AI Experiment

Daniel Kelly
Daniel Kelly
Updated: December 25th 2024

In full-stack development, speed and efficiency matter. Thatā€™s where Bolt.new comes inā€”a game-changing AI tool that helps you build Nuxt apps, generate APIs, and design UIs in no time. By leveraging AI, it simplifies the coding process, so you can focus on creating and deploying powerful applications faster than ever. Ready to see how it works? Letā€™s dive into building a full-stack Nuxt app with Bolt.new!

Introduction to Bolt.new

bolt.new, developed by the StackBlitz team, is an amazing and powerful AI tool designed to streamline web development by automating code generation. This tool makes it easier to build both front-end and back-end logic without the need for extensive manual coding.

It supports popular frameworks like Nuxt, Vue, React, and Astro, allowing you to quickly create dynamic UIs, generate API endpoints, and handle complex full-stack development tasks. By leveraging AI, Bolt.new accelerates your workflow and eliminates the repetitive coding tasks that slow down your progress.

Bolt.new also makes integrating persistent storage easier with tools like Nitroā€™s useStorage function, enabling smooth data management in your applications. This makes it an ideal tool for developers who want to quickly spin up projects without sacrificing flexibility or control.

In this article, weā€™ll explore how to use Bolt.new to create a Nuxt-based blog, showcasing its ability to handle both front-end UI generation and back-end API management. Letā€™s dive in and see how well it performs in real-world development scenarios.

Bootstrapping the Project

Letā€™s start the Nuxt project by prompting bolt to create a blog for us with the following prompt:

Let's create a blog about video games using Nuxt and Nuxt Content. 
It should use TailwindCSS for styling and have a cool, modern gamer vibe.

This produces a stylish and functional starting point that even has some relevant dummy posts! It has a homepage, a blog listing page, and a post page that uses a dynamic slug parameter to fetch the proper post all setup properly to manage content with Nuxt Content.

Bootstrap new Nuxt app with Bolt AI

Iterating on A Bolt.new Nuxt Project

The images are currently all broken. Letā€™s add in some placeholder images from lorem picsum.

use placeholder images from lorem picsum for all the images
Ask Bolt AI to create placeholder images

Making Relative Time Displays with Bolt and the VueUse Nuxt Module

Currently each of the blog posts has a published at date that is absolute like 4/2/2024. What if we wanted to make the times relative. We can definitely do that! I just so happen to know that VueUse has a great composable for this, so letā€™s see if Bolt uses it.

Can we make the date display relative (like 1 day ago, etc) 
and then only show the human readable date on hover? Use the `useTimeAgo`
composable from the VueUse Nuxt module.

This does the trick! Bolt installs the VueUse Nuxt module and even creates an abstracted RelativeDate component and puts it into place in the blog post page.

Bolt AI using the VueUse Nuxt module

There were a couple hang ups in this step though, an extra <content> tag got randomly added to the [...slug] component (presumably this is used by Bolt under the hood when generating new content) and since bolt had to run npm install, the dev server stopped. Both were easily fixed with a little manual attention though.

Persistent Data Storage in Bolt for Comments with useStorage

At this point, weā€™ve got a decently functional blog. Letā€™s use the useStorage function from nitro to support key-value storage (or KV storage) for post comments.

The useStorage function abstracts the KV storage services provided by various hosting platforms, including Cloudflare's KV, Netlifyā€™s Blob Storage, and Vercel's KV storage. This abstraction offers flexibility, allowing us to deploy our applications across multiple platforms. For development, we'll use in-memory storage to simulate data persistence without external dependencies.

Add comments support to the single blog post page. 
Create an API endpoints to get and store comments. 
In the API endpoints, use the useStorage function from Nitro 
to store comments in KV storage.

This prompt getā€™s a pretty nice UI bootstrapped and writes the code for a couple API endpoints.

Bolt AI created a stylish comments section in Nuxt

When trying to post a comment, though I get an error that crypto is not defined.

Nuxt error: Crypto is not defined

The node version running in bolt.new is Node 18, so the crypto module isnā€™t available. Itā€™s being used in the API endpoint for creating new comments to generate a random UUID. No problem, I can install nanoid with the terminal tab and generate a UUID that way instead.

Terminal command to install nanoid

This time it works! Even when I refresh the page, my comment sticks around because itā€™s persisted to the running node applicationā€™s memory. When deploying Iā€™d simply need to configure the KV storage driver of my choice in nuxt.config.ts

Bolt AI use KV Storage driver in the Nuxt app

Rich Text Comments with Tip Tap Editor

Plain text comments are fine, but supporting rich text with options like bold and italic would be even nicer. TipTap editor can take care of that no problem!

Provide rich text support for comments with tip tap.
Bolt AI added rich text support in Nuxt

It even escapes the HTML output by TipTap to prevent malicious JavaScript injection and uses the Tailwind typography plugin to style the output.

Bolt AI implemented HTML escaping in the rich text editor

Authorization with Nuxt Auth Utils

Letā€™s try making this just a little more complicated by implementing authentication with Nuxt Auth Utils. This means that users will have to login with github to make a comment. Iā€™m also going to hint to bolt where to find docs for Nuxt auth utils as itā€™s pretty new and I want to make sure bolt handles things accurately.

Let's implement authentication with Nuxt Auth Utils 
(https://github.com/atinux/nuxt-auth-utils) and require a user 
to login with github to make a comment.

This time I get mixed resultsā€¦.

The Good!

  • The UI looks great!

    Screenshot of the UI created by Bolt AI

  • A Sign-In link was added the the main nav

    Screenshot of the sign in button added by Bolt AI

  • Bolt walks me through the setup needed on the Github side and even gives me placeholders for the needed env vars

    Bolt AI gives instructions to make the Nuxt app authentication work

The Bad

Some things donā€™t go quite as wellā€¦ There are several errors I have to fix manually with the help of the Nuxt auth utils docs, including:

Even after making these changes, auth still didnā€™t quite work so I stopped trying and asked bolt to revert the auth feature:

the nuxt auth utils didn't work, let's roll that back

and too be fair it did a good job rolling things back to the previous state, I only had to delete one file manually (that is server side route I added manually above to handle github auth)

Prompts and Finished Project

Here are all my prompts I used to generate the finished project. This easy copy was made possible with a bookmarklet shared by StackBlitz engineer Tomek Sułkowski.

Let's create a blog about video games using Nuxt and Nuxt Content. It should use TailwindCSS for styling and have a cool, modern gamer vibe.

use placeholder images from lorem picsum for all the images

Can we make the date display relative (like 1 day ago, etc)
and then only show the human readable date on hover? Use the useTimeAgo
composable from the VueUse Nuxt module.

Add comments support to the single blog post page. Create an API endpoints to get and store comments. In the API endpoints, use the useStorage function from Nitro to store comments in KV storage.

Provide rich text support for comments with tip tap.

Let's implement authentication with Nuxt Auth Utils (https://github.com/atinux/nuxt-auth-utils) and require a user to login with github to make a comment.

the nuxt auth utils didn't work, let's roll that back

Some Closing Remarks and Tips

In my experience, Bolt.new is the best way to generate code from scratch when working on a new web application or app. It certainly isnā€™t perfect but is a huge step forward. Besides this example blog, Iā€™ve been experimenting with it for other purposes and found the following practices to be helpful:

  • Let bolt do the heavy lifting on creating the front-end UI and ask it to use dummy info within API endpoints (then hookup your database yourself)
  • Open in StackBlitz every once and a while for better manual editing and save the code to a github repo before opening up again in bolt to continue iterating with bolt
  • Provide a markdown file with hints about how you like things done and tell bolt to reference it for generating code based on your preferences

Related Courses

Start learning Vue.js for free

Daniel Kelly
Daniel Kelly
Daniel is the lead instructor at Vue School and enjoys helping other developers reach their full potential. He has 10+ years of developer experience using technologies including Vue.js, Nuxt.js, and Laravel.

Comments

Latest Vue School Articles

Why Vue.js is a Great Starting Point for New Coders

Why Vue.js is a Great Starting Point for New Coders

Dive into Vue.js as a beginner with our comprehensive guide. Learn why Vue is perfect for starting your web development journey, with insights into its community, learning resources, and real-world uses.
Eleftheria Batsou
Eleftheria Batsou
The Vue Form Component Pattern: Robust Forms Without the Fuss

The Vue Form Component Pattern: Robust Forms Without the Fuss

Learn to create easy to use Vue forms without a library and take advantage of native HTML validation.
Daniel Kelly
Daniel Kelly

Our goal is to be the number one source of Vue.js knowledge for all skill levels. We offer the knowledge of our industry leaders through awesome video courses for a ridiculously low price.

More than 200.000 users have already joined us. You are welcome too!

Follow us on Social

Ā© All rights reserved. Made with ā¤ļø by BitterBrains, Inc.