DEV Community

Cover image for Advance Features and Deploying the Project (Nerd Streetwear Online Store) Part III
Nebojsa Radakovic
Nebojsa Radakovic

Posted on

Advance Features and Deploying the Project (Nerd Streetwear Online Store) Part III

From ideation to examples to step-by-step setup, the side hustle nerd t-shirt store built with Astro, Crystallize, and Stripe for payment by ChatGPT and proofread for accuracy.

This is a four-piece article:
1️⃣ Bringing Idea to Life and Setting Up the Backend
2️⃣ Building the Frontend with Astro and Integration with Stripe
3️⃣ Advance Features and Deploying the Project
4️⃣ Final Testing, Going Live, and Summary

The backend and frontend are done. Let’s examine any advanced features I may need and where to deploy the project.

4. Advanced Features

To enhance the functionality and user experience of my DisBar online store, consider implementing the following advanced features.

Product Filtering

Product filtering allows users to narrow the product catalog based on specific criteria, such as size, color, or price.

  1. Setting Up Filters:
    • Define the filtering options based on your product attributes (e.g., size, color).
    • Create a FilterComponent that allows users to select their preferences.
  2. Implementing Filter Logic:
    • Use Crystallize Discovery or Search API to update the product list dynamically based on the selected filters via GraphQL queries.
  3. Integrating Filters on the Frontend:
    • Display the filter options prominently on the product listing page.
    • Ensure that the filtering is intuitive and provides real-time feedback.

Wishlist Functionality

Adding a wishlist feature allows users to save products they are interested in and return to them later.

  1. Creating a Wishlist Context:
    • Use React Context or another state management solution to handle the wishlist logic.
    • Allow users to add and remove products from the wishlist.
  2. Storing Wishlist Data:
    • Store the wishlist data in local storage or sync it with the user’s account if authentication is implemented.
  3. Displaying the Wishlist:
    • Create a wishlist page that displays all the saved products.
    • Provide options to move items from the wishlist to the shopping cart.

Internationalization (i18next)

To reach a global audience, implement multi-language support using a library like i18next.

  1. Setting Up i18next:
    • Install i18next and configure it with your available languages.
    • Define translation files for each language, or use the Crystallize translation app to do the work for you.
  2. Integrating i18n in Astro:
    • Wrap your components with translation functions to serve content in the selected language.
    • Provide a language switcher on the frontend to allow users to select their preferred language.
  3. Handling Dynamic Content:
    • Ensure that product descriptions, reviews, and other dynamic content are translated appropriately. In Crystallize, components are multilingual, so you can fetch your content based on the user's chosen language.

SEO and Performance Optimizations

Optimizing your site for search engines and performance is crucial for visibility and user experience.
SEO and Performance Optimizations

  1. SEO Best Practices:
    • Use semantic HTML and appropriate meta tags for all pages.
    • Generate a sitemap and robots.txt file for better crawlability.
  2. Structured Data:
    • Implement JSON-LD structured data to enhance search engine understanding of your content.
    • Add structured data for products, reviews, and breadcrumbs.
  3. Lazy Loading Images:
    • Use the loading="lazy" attribute on images to defer the loading of off-screen images until the user scrolls to them.
    • This improves initial page load times and overall performance.
  4. Minimizing JavaScript:
    • Ensure that your Astro project delivers minimal JavaScript to the client by default.
    • Use Astro’s built-in optimizations to split and defer non-essential scripts.

By following these steps, or the steps I mentioned in the SEO checklist, you’ll create a highly functional, visually appealing, and performant e-commerce site that meets the needs of your target audience while showcasing your expertise in modern web development technologies.

5. Deploying the Project

Once my DisBar online store is built and tested, the next step is to deploy it so users can access it. This involves choosing a hosting platform for your eCommerce frontend, configuring continuous integration and deployment (CI/CD), and performing final testing before going live.

Choosing a Hosting Platform

Several hosting platforms are well-suited for deploying an Astro project. Here are some of the top options:

  1. Vercel:
    • Strengths: Vercel is optimized for static site generation and serverless functions, making it an excellent choice for deploying Astro projects. It offers fast build times, automatic SSL certificates, and a global content delivery network (CDN) for fast load times.
    • Integration: Vercel integrates seamlessly with GitHub, GitLab, and Bitbucket, allowing automatic deployments from your repository.
    • Ease of Use: The deployment process is straightforward—simply connect your Git repository, and Vercel will automatically detect and build your Astro project.
  2. 🗄️🌐☁🖥️Netlify:
    • Strengths: Netlify is another powerful platform for deploying static sites and serverless functions. It provides automatic deployments, continuous deployment, and instant rollbacks. Netlify also has built-in forms, identity management, and analytics.
    • Integration: Like Vercel, Netlify integrates with Git platforms for automatic deployments and offers a simple, user-friendly interface.
    • Additional Features: Netlify’s Build Plugins and integrations can help automate tasks like image optimization, SEO checks, and more.
  3. AWS Amplify:
    • Strengths: AWS Amplify is a robust platform for deploying full-stack applications. It’s backed by AWS infrastructure and offers scalability and a wide range of services, including hosting, authentication, and real-time data.
    • Integration: Amplify integrates with popular Git services and offers a CI/CD pipeline that supports automatic deployments.

Choosing the Right Platform:

Small to Medium Projects: Vercel and Netlify are excellent choices, offering ease of use, powerful features, and automatic deployments.

Large or Complex Projects: AWS Amplify might be more suitable if you need more control over the infrastructure and plan to integrate additional AWS services.

Simple Static Sites: GitHub Pages can be a good option if your project is straightforward and doesn’t require advanced features.

There is a fantastic post to dig deeper into the subject here > Where To Host Your eCommerce Frontend?

Connect everything. Build anything. Netlify.

6. Deploying DisBar online store project on Netlify

I’ve decided to deploy DisBar online store project on 🗄️🌐☁🖥️ Netlify. A couple of reasons for that. I like them from day one. They support Astro, and the process is straightforward, thanks to Netlify's powerful tools for hosting, continuous deployment, and serverless functions.

Below is a detailed guide on deploying your Astro-based project integrated with Crystallize and Stripe on Netlify.

Step 1: Set Up Your Project for Deployment

Before deploying to Netlify, ensure that your project is properly set up for production:

  • Build Your Project: Ensure your Astro project builds correctly. You can do this by running:
npm run build
Enter fullscreen mode Exit fullscreen mode
  • This command will generate a dist/ folder containing Astro's generated static files, which will be deployed to Netlify.
  • Install Necessary Plugins: For optimal deployment on Netlify, you might want to use the Netlify adapter for Astro, which configures your project specifically for deployment on Netlify:
npm install @astrojs/netlify --save
Enter fullscreen mode Exit fullscreen mode

In your astro.config.mjs file, configure Astro to use the Netlify adapter:

import { defineConfig } from 'astro/config';
import netlify from '@astrojs/netlify/functions';

export default defineConfig({
  output: 'server',
  adapter: netlify(),
});
Enter fullscreen mode Exit fullscreen mode

Step 2: Set Up a Netlify Account

If you haven’t already, sign up for a Netlify account:

  • Sign Up: Go to Netlify and sign up using your GitHub, GitLab, or Bitbucket account. This will allow Netlify to link directly to your project repository.
  • Create a New Site: Once logged in, click "New site from Git" on your Netlify dashboard.

Step 3: Connect Your Repository

  • Choose Your Git Provider: Select the Git provider where your project repository is hosted (GitHub, GitLab, Bitbucket).
  • Authorize Netlify: Authorize Netlify to access your repositories.
  • Select Your Repository: Choose the repository that contains your DisBar project. Netlify will display a list of your repositories; simply click on the correct one.

Step 4: Configure the Deployment Settings

  • Set the Build Command: In the "Build command" field, enter:
npm run build
Enter fullscreen mode Exit fullscreen mode

This tells Netlify to run the build process for your Astro project.

  • Set the Publish Directory: In the "Publish directory" field, specify:
dist
Enter fullscreen mode Exit fullscreen mode

This is the directory where Astro outputs the final build files.

  • Environment Variables: If your project relies on environment variables (e.g., for Crystallize API keys or Stripe keys), add them under "Environment" settings. For example:
CRYSTALLIZE_TENANT_IDENTIFIER=your-tenant-identifier
STRIPE_SECRET_KEY=your-stripe-secret-key
ASTRO_ENV=production
Enter fullscreen mode Exit fullscreen mode

Ensure that sensitive information is stored as environment variables rather than hard-coded in your project.

  • Deploy Preview Settings (Optional): You can configure settings for deploy previews, which allow you to preview changes before they go live. This is especially useful for collaborative projects.

Step 5: Deploy the Site

  • Deploy Your Site: After configuring your settings, click "Deploy site." Netlify will start the deployment process, which includes pulling the code from your repository, installing dependencies, building the project, and deploying the static files.
  • Monitor the Deployment: You can monitor the deployment process in real-time through the Netlify dashboard. If there are any issues, Netlify will provide error messages to help you troubleshoot.

Step 6: Configure DNS and Domain Settings

If you want to use a custom domain:

  • Add a Custom Domain: In the Netlify dashboard, go to your site's "Domain settings." Click "Add a custom domain" and enter your domain name.
  • Update DNS Settings: You’ll need to update the DNS settings for your domain registrar to point to Netlify’s servers. Netlify provides the necessary DNS records. If you’ve purchased the domain through a provider like Namecheap or GoDaddy, follow their instructions to update the DNS settings.
  • Enable HTTPS: Netlify provides free SSL certificates via Let’s Encrypt. For secure access, ensure that HTTPS is enabled in your domain settings. Step 7: Set Up Continuous Deployment
  • Automatic Deployments: With Netlify connected to your Git repository, every time you push a commit to your main branch (or any branch you’ve specified), Netlify will automatically rebuild and deploy your site. This continuous deployment setup ensures that your live site is always up-to-date with the latest changes.
  • Branch Previews: Netlify allows you to deploy previews for pull requests and branches. This helps test changes before merging them into the main branch.

Step 8: Post-Deployment Checks

  • Test Your Live Site: After deployment, thoroughly test your live site to ensure everything functions correctly. This includes testing payment processing with Stripe, browsing product pages, using filters, and checking device responsiveness.
  • Set Up Analytics and Monitoring: Integrate Google Analytics or another analytics tool to track user behavior on your site. Enable Netlify’s built-in analytics for server-side metrics like page views, traffic sources, and performance data.
  • Configure Redirects and Headers (Optional): You can create a _redirects file to handle URL redirects or a _headers file to manage HTTP headers (e.g., for security purposes).

Step 9: Monitor and Optimize

  • Monitor Performance: Use Netlify’s performance monitoring tools or external tools like Lighthouse to ensure your site loads quickly and efficiently. Regularly check for any new errors or issues that arise post-launch.
  • Ongoing Improvements: Optimize and improve your site’s performance, design, and functionality based on analytics and user feedback.

By following these steps, you can successfully deploy any online store on Netlify, ensuring a smooth, reliable, and secure online shopping experience for your customers.

AND we’re at the end of part three of this guide about building a side hustle using Astro, Crystallize, and Stripe for payment. Next, final testing and wrap-up.

Next 👉 Final Testing, Going Live, and Summary

¯_(ツ)_/¯

If you enjoyed reading this, please support my efforts by recommending and sharing this page to help others find it! Let me know what you think.

Please share your feedback and suggestions in the comment section below.

Top comments (0)