/bolt.new-ai-integrations

Bolt.new AI and AfterShip integration: Step-by-Step Guide 2025

Integrate Bolt.new AI with AfterShip and boost your shipping efficiency. Follow our step-by-step guide to streamline tracking and enhance your operations.

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free No-Code consultation

How to integrate Bolt.new AI with AfterShip?

 

Setting Up Dependencies

 

Since Bolt.new AI doesn’t support a terminal, you need to add any dependency directly in your project’s package.json file. Open your package.json and add the following within the "dependencies" section to include axios:


{
  "dependencies": {
    "axios": "0.27.2"
    // Other dependencies if needed
  }
}

 

Creating the AfterShip Integration File

 

In your project’s file tree, create a new file at src/integrations/aftership.ts. This file will contain the TypeScript code needed to integrate with AfterShip. Paste the following code into that file:


import axios from "axios";

// Replace with your actual AfterShip API key or better load it from env variables
const AFTERSHIPAPIKEY = process.env.AFTERSHIPAPIKEY || "YOURAFTERSHIPAPI_KEY";

// Base URL for the AfterShip API
const AFTERSHIPBASEURL = "https://api.aftership.com/v4";

/**
- Track a shipment using AfterShip API.
- @param slug - The courier slug (e.g., "ups", "fedex").
- @param trackingNumber - The shipment tracking number.
 */
export async function trackShipment(slug: string, trackingNumber: string): Promise<any> {
  try {
    const url = ${AFTERSHIP_BASE_URL}/trackings/${slug}/${trackingNumber};
    const response = await axios.get(url, {
      headers: {
        "aftership-api-key": AFTERSHIPAPIKEY,
        "Content-Type": "application/json"
      }
    });
    return response.data;
  } catch (error) {
    throw new Error(Error fetching tracking data: ${error});
  }
}

 

Using the AfterShip Integration in Your Project

 

Decide where in your Bolt.new AI project you need to use shipment tracking. For example, if your main application logic is in src/index.ts, open that file and import the newly created function. Add the code snippet in the place where you want to perform tracking:


import { trackShipment } from "./integrations/aftership";

// Example usage: Tracking a shipment
async function demoTracking() {
  const courierSlug = "ups";         // Replace with the appropriate courier slug
  const trackingNum = "1Z999AA10123456784";  // Replace with a real tracking number
  
  try {
    const trackingData = await trackShipment(courierSlug, trackingNum);
    console.log("Tracking Data:", trackingData);
  } catch (error) {
    console.error("Error tracking shipment:", error);
  }
}

// Call the demoTracking function wherever it fits in your application flow.
demoTracking();

 

Configuring Environment Variables

 

To securely store your AfterShip API key, add it to your environment variables. In Bolt.new AI, you can typically set environment variables using the project’s secrets configuration. Assign your API key to the variable name AFTERSHIPAPIKEY. This way, the code in aftership.ts can access the key securely via process.env.AFTERSHIPAPIKEY.

 

Reviewing and Testing the Integration

 

After you have added the dependency setup in package.json, created the src/integrations/aftership.ts file, and imported the tracking function in your main file, save your changes. Use the Bolt.new AI interface’s Run button to execute your project. The console should display tracking information if the tracking number and courier slug are valid and your API key is correctly configured.

 

Final Notes

 

Ensure that you replace placeholder values such as "YOURAFTERSHIPAPI_KEY", courier slug, and tracking number with actual values. Also, remember to configure your environment variables in Bolt.new AI’s secrets management section for production use.

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

Client trust and success are our top priorities

When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.

Rapid Dev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with. They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

CPO, Praction - Arkady Sokolov

May 2, 2023

Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost. He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Co-Founder, Arc - Donald Muir

Dec 27, 2022

Rapid Dev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space. They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Co-CEO, Grantify - Mat Westergreen-Thorne

Oct 15, 2022

Rapid Dev is an excellent developer for no-code and low-code solutions.
We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Co-Founder, Church Real Estate Marketplace - Emmanuel Brown

May 1, 2024 

Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 
This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Production Manager, Media Production Company - Samantha Fekete

Sep 23, 2022