Skip to main content
RapidDev - Software Development Agency
bolt-ai-integrationsBolt Chat + API Route

How to Integrate Bolt.new with Segment

To add Segment to your Bolt.new app, install `@segment/analytics-next` (the browser SDK) and initialize it with your Segment Write Key. Segment's SDK sends events directly from the browser to Segment's servers, which then forward them to all your configured destinations (Mixpanel, Amplitude, Google Analytics, data warehouses) automatically. The SDK works in Bolt's WebContainer preview. Configure destinations in the Segment dashboard — no code changes needed to add new analytics tools.

What you'll learn

  • How Segment works as a data pipeline and why integrating once saves you from adding separate SDKs for every analytics tool
  • How to install and initialize @segment/analytics-next in a Vite or Next.js Bolt app
  • How to use Segment's standard identify, track, and page calls to capture user behavior
  • How to add and configure analytics destinations (Mixpanel, Amplitude, Google Analytics) in the Segment dashboard without code changes
  • How to send server-side events from a Next.js API route using Segment's HTTP Tracking API
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Intermediate16 min read25 minutesAnalyticsApril 2026RapidDev Engineering Team
TL;DR

To add Segment to your Bolt.new app, install `@segment/analytics-next` (the browser SDK) and initialize it with your Segment Write Key. Segment's SDK sends events directly from the browser to Segment's servers, which then forward them to all your configured destinations (Mixpanel, Amplitude, Google Analytics, data warehouses) automatically. The SDK works in Bolt's WebContainer preview. Configure destinations in the Segment dashboard — no code changes needed to add new analytics tools.

Segment in Bolt.new: Integrate Your Analytics Stack Once, Route Everywhere

Segment is a customer data platform that solves the 'analytics sprawl' problem: instead of writing separate integrations for Google Analytics, Mixpanel, Amplitude, your data warehouse, your email marketing tool, and your CRM, you integrate Segment once and configure all your destinations through Segment's dashboard. When you add a new analytics tool or switch providers, you change a setting in Segment — not your codebase. For Bolt apps that might need to swap tools as they scale, this architectural flexibility is significant.

The core Segment data model uses three calls: identify() links events to a known user with properties, track() records events with properties, and page() records page views. These three calls map to the standard analytics schema understood by every Segment destination. When you call track('Subscription Upgraded', { plan: 'pro', mrr: 49 }), Segment forwards that event to Mixpanel as a standard Mixpanel event, to Amplitude as an Amplitude event, and to your Snowflake warehouse as a row — all from a single track() call in your code.

Segment's free tier (the Developer plan) includes 1,000 Monthly Tracked Users (MTUs) with unlimited events per user and access to all core integrations. This is sufficient for early-stage apps until you reach 1,000 unique active users per month. The Team plan ($120/month) covers up to 10,000 MTUs. For Bolt developers building and iterating quickly, Segment's abstraction layer is particularly valuable: you can change your analytics stack without touching your application code.

Integration method

Bolt Chat + API Route

Segment's `@segment/analytics-next` browser SDK communicates directly from the user's browser to Segment's API over HTTPS — it does not go through Bolt's WebContainer server runtime. This means all client-side event tracking works in the Bolt preview. For server-side event tracking (e.g., sending events from API routes after database operations), use Segment's Node.js HTTP Tracking API from a Next.js API route to keep your Write Key server-side.

Prerequisites

  • A Segment account (free at segment.com) with a Source created — choose 'JavaScript (Browser)' as the source type for the browser SDK
  • Your Segment Write Key from your source settings (Settings → API Keys → Write Key)
  • A Bolt.new project — Vite (React) or Next.js both work for the browser SDK
  • For server-side events: a Next.js Bolt project with API routes and a server-side Write Key (same key, used server-side with no NEXT_PUBLIC_ prefix)

Step-by-step guide

1

Create a Segment Source and Get Your Write Key

Before installing the SDK, you need a Segment Source. A Source represents a single data origin — your web app. Log into app.segment.com, click 'Add Source' (or go to Connections → Sources → Add Source). Search for 'JavaScript' and select 'Javascript (Browser)'. Give it a name matching your app ('My Bolt App' or your actual app name) and click 'Add Source'. After creating the source, click on it to open the source details. Go to Settings → API Keys. You will see a Write Key — copy it. The Write Key looks like a long alphanumeric string. This is the only credential needed for browser-side tracking. It is safe to expose as a VITE_ variable or NEXT_PUBLIC_ variable because it only authorizes writing events to your Segment source — it cannot read your data or access other sources. For production apps, Segment recommends using separate Sources for development and production environments. Create a second source called 'My Bolt App (Dev)' and use its write key in your .env file, reserving the production write key for your deployed app. This prevents development test traffic from appearing in your production analytics. Understand Segment's destination model before proceeding: after events arrive in Segment, nothing goes anywhere until you configure destinations. Go to your Source → Connections → Add Destination to add Mixpanel, Google Analytics, Amplitude, or any of the 300+ available destinations. Segment will forward all future events to configured destinations automatically. This tutorial covers the SDK setup — destination configuration happens in the Segment dashboard.

Bolt.new Prompt

Set up Segment in my Bolt.new app. Install @segment/analytics-next. Create lib/segment.ts that exports an initialized AnalyticsBrowser instance. Read the write key from import.meta.env.VITE_SEGMENT_WRITE_KEY. Export analytics as the default export. Create a .env file with VITE_SEGMENT_WRITE_KEY=YOUR_WRITE_KEY_HERE as a placeholder. Initialize the analytics instance using AnalyticsBrowser.load({ writeKey }) and export it for use throughout the app.

Paste this in Bolt.new chat

lib/segment.ts
1// lib/segment.ts
2import { AnalyticsBrowser } from '@segment/analytics-next';
3
4const writeKey = import.meta.env.VITE_SEGMENT_WRITE_KEY as string;
5
6if (!writeKey && import.meta.env.DEV) {
7 console.warn('Segment: VITE_SEGMENT_WRITE_KEY is not set — analytics disabled');
8}
9
10export const analytics = writeKey
11 ? AnalyticsBrowser.load(
12 { writeKey },
13 {
14 integrations: {
15 'Segment.io': {
16 deliveryStrategy: {
17 strategy: 'batching',
18 config: { size: 10, timeout: 5000 },
19 },
20 },
21 },
22 }
23 )
24 : null;
25
26// .env
27// VITE_SEGMENT_WRITE_KEY=YOUR_WRITE_KEY_HERE

Pro tip: Create separate Segment Sources for development and production. Use the dev source write key in .env for local development and the production write key in your Netlify/Bolt Cloud environment variables. This prevents test events from appearing in your production analytics reports.

Expected result: @segment/analytics-next installs without errors. The Segment analytics object is exported from lib/segment.ts. No TypeScript errors. Check the Segment Source Debugger (Connections → Sources → your source → Debugger) — you should see events arrive when you interact with your app.

2

Implement Identify, Track, and Page Calls

Segment's API is built around three core methods that form the foundation of any analytics implementation. Understanding when to use each is essential for producing clean, consistent data. identify(userId, traits) — call this when you know who the user is, typically after login or signup. The first argument is the user's unique ID (from your database — a UUID, not an email). The second argument is an object of user traits: email, name, plan, createdAt. Segment passes these traits to all destinations that support user profiles (Mixpanel people properties, Amplitude user properties, Intercom contact details). Call identify once per session when auth state changes, then reset on logout. track(event, properties) — call this for any user action you want to measure. Event names in Segment follow Title Case convention ('Subscription Upgraded', not 'subscription_upgraded') — this is Segment's recommended style and maps cleanly to destinations that expect specific naming. Properties add context: { plan: 'pro', mrr: 49, billingCycle: 'monthly' }. page(name, properties) — call this on every page navigation. For Vite single-page apps, call page() when your router changes routes. For Next.js App Router, call page() in a usePathname effect. Segment's page call tracks the page name, URL, referrer, and any custom properties you pass. Many Segment destinations use page() to track pageviews automatically. All three methods return a Promise — you can await them if you need confirmation that the event was queued, but usually fire-and-forget is appropriate. The SDK batches events and sends them in groups for efficiency, so individual track() calls do not create individual network requests.

Bolt.new Prompt

Add Segment identify, track, and page calls to my Bolt app. Create lib/analytics.ts that imports the analytics instance from lib/segment.ts and exports typed wrapper functions. Add page tracking to my router: in my React Router setup (or usePathname in Next.js), call analytics.page() on every route change. When a user logs in via Supabase Auth, call analytics.identify() with their user ID and traits. Create typed track functions for: signupCompleted, projectCreated, exportCompleted, subscriptionUpgraded.

Paste this in Bolt.new chat

lib/analytics.ts
1// lib/analytics.ts
2import { analytics } from './segment';
3
4type Properties = Record<string, string | number | boolean | null>;
5
6export const Analytics = {
7 // Call after user logs in:
8 identify: (userId: string, traits: {
9 email?: string;
10 name?: string;
11 plan?: string;
12 createdAt?: string;
13 [key: string]: unknown;
14 }) => {
15 analytics?.identify(userId, traits);
16 },
17
18 // Call on logout:
19 reset: () => {
20 analytics?.reset();
21 },
22
23 // Generic track call:
24 track: (event: string, properties: Properties = {}) => {
25 analytics?.track(event, properties);
26 },
27
28 // Call on route change:
29 page: (name?: string, properties: Properties = {}) => {
30 analytics?.page(name, properties);
31 },
32
33 // Typed event helpers:
34 signupCompleted: (method: string) =>
35 Analytics.track('Signup Completed', { method }),
36
37 projectCreated: (type: string, template: boolean) =>
38 Analytics.track('Project Created', { project_type: type, template_used: template }),
39
40 subscriptionUpgraded: (fromPlan: string, toPlan: string, mrr: number) =>
41 Analytics.track('Subscription Upgraded', { from_plan: fromPlan, to_plan: toPlan, mrr }),
42
43 exportCompleted: (format: string) =>
44 Analytics.track('Export Completed', { format }),
45};

Pro tip: Segment recommends Title Case event names with past tense verbs: 'Subscription Upgraded', 'File Exported', 'Project Created'. Avoid camelCase or snake_case for Segment event names — Title Case is the convention that all Segment destination mappings and documentation use.

Expected result: Events appear in the Segment Source Debugger in real-time. The Debugger shows the full event payload including properties and context. Identify calls create or update user profiles in the People section if you have a People destination configured.

3

Configure Analytics Destinations in the Segment Dashboard

One of Segment's most powerful features is that you configure where your data goes without writing any integration code. After events arrive in Segment, you connect destinations from the dashboard — and Segment forwards all matching events automatically. To add a destination: go to your Source in the Segment dashboard → Connections → Add Destination. Browse or search for your tool. Popular destinations for Bolt apps: Mixpanel (funnel and retention analytics), Amplitude (product analytics with session replay), Google Analytics 4 (traffic and conversion tracking), Intercom (user messaging triggered by events), and data warehouses like Snowflake or BigQuery for raw data analysis. Each destination has its own configuration. For Mixpanel, you need to enter your Mixpanel Project Token. For Google Analytics 4, you enter your Measurement ID. For data warehouses, you enter connection credentials. Segment's UI guides you through each destination's requirements. Destination filters let you control which events go to which tools. For example, you might send all events to your data warehouse but only send payment events to Intercom for customer messaging. Configure this in the destination settings under Filters → Add Filter. For browser-based destinations (like Google Analytics 4's gtag.js), Segment can load the destination SDK directly without you adding it to your HTML. This 'device-mode' integration loads the third-party script through Segment's SDK, keeping your app's HTML clean. Cloud-mode destinations (like Mixpanel's server-to-server API) receive events server-side through Segment's infrastructure without any client-side SDK loading.

Bolt.new Prompt

I've already set up Segment in my Bolt app. Now I want to add Mixpanel and Google Analytics 4 as destinations in the Segment dashboard. Show me the configuration I need in Segment and how to verify the destinations are receiving events. Also create a simple test component in my app that fires a 'Test Event' with a timestamp property so I can verify the full pipeline is working end-to-end through Segment to both destinations.

Paste this in Bolt.new chat

components/SegmentTest.tsx
1// components/SegmentTest.tsx (development testing only)
2'use client';
3
4import { Analytics } from '@/lib/analytics';
5
6export function SegmentTest() {
7 if (process.env.NODE_ENV !== 'development') return null;
8
9 const fireTestEvent = () => {
10 Analytics.track('Segment Test Event', {
11 timestamp: new Date().toISOString(),
12 source: 'bolt_preview',
13 test: true,
14 });
15 console.log('Segment test event fired — check Source Debugger');
16 };
17
18 const fireTestIdentify = () => {
19 Analytics.identify('test-user-123', {
20 email: 'test@example.com',
21 name: 'Test User',
22 plan: 'free',
23 });
24 console.log('Segment identify fired — check Source Debugger');
25 };
26
27 return (
28 <div style={{ position: 'fixed', bottom: 16, right: 16, zIndex: 9999 }}>
29 <button onClick={fireTestEvent}>Fire Test Event</button>
30 <button onClick={fireTestIdentify}>Fire Identify</button>
31 </div>
32 );
33}

Pro tip: After configuring a new destination in Segment, wait 1-2 minutes for the configuration to propagate, then fire a test event from your app. Check both the Segment Source Debugger (to confirm Segment received the event) and the destination's own live events view to confirm forwarding worked.

Expected result: Events appear in the Segment Source Debugger. After configuring Mixpanel and GA4 as destinations, those same events appear in Mixpanel's Live Events and GA4's Realtime report within a few seconds. No separate Mixpanel or GA4 SDKs are needed in your codebase.

4

Send Server-Side Events from Next.js API Routes

Some analytics events should be sent from the server rather than the browser. Server-side events are more reliable (not blocked by ad blockers), cannot be tampered with by the client, and can include server-only data (like database IDs assigned after creation). Common server-side events: subscription created (after Stripe webhook confirms payment), account deleted (after database record removal), or any event where you need to guarantee delivery regardless of whether the browser tab is still open. Segment's HTTP Tracking API accepts POST requests to https://api.segment.io/v1/track with Basic Auth (Write Key as username, empty password). The request body matches Segment's standard event format: userId, event, properties, and optional context and timestamp. You can use your same Write Key for server-side calls — but it must be a server-side environment variable (no NEXT_PUBLIC_ prefix) to prevent exposure in client bundles. For Next.js Bolt apps, send server-side events from API routes — typically after database operations succeed. The pattern: receive webhook or form submission, validate and save to database, then send Segment event as the final step. If Segment delivery fails, it should not roll back your database operation — wrap the Segment call in a try/catch and log errors without throwing. Note about Bolt WebContainer: the server-side HTTP Tracking API call (a simple fetch to api.segment.io) should work in the WebContainer preview since it is a standard outbound HTTPS request. However, some complex authentication patterns can behave differently in WebContainers than in production. If you encounter issues, deploy to Netlify to test server-side Segment calls in a proper Node.js environment.

Bolt.new Prompt

Create a server-side Segment tracking utility in lib/segment-server.ts for use in Next.js API routes. It should export a trackServer function that sends events to Segment's HTTP Tracking API using fetch. Use SEGMENT_WRITE_KEY (server-side only, no NEXT_PUBLIC_ prefix) for authentication. In my Stripe webhook handler at app/api/webhooks/stripe/route.ts, after a checkout.session.completed event saves the subscription to the database, call trackServer with the user ID and 'Subscription Created' event. Handle Segment API errors gracefully without throwing.

Paste this in Bolt.new chat

lib/segment-server.ts
1// lib/segment-server.ts
2const SEGMENT_WRITE_KEY = process.env.SEGMENT_WRITE_KEY;
3
4interface SegmentTrackPayload {
5 userId: string;
6 event: string;
7 properties?: Record<string, unknown>;
8 timestamp?: string;
9 context?: {
10 ip?: string;
11 userAgent?: string;
12 [key: string]: unknown;
13 };
14}
15
16export async function trackServer(
17 payload: SegmentTrackPayload
18): Promise<void> {
19 if (!SEGMENT_WRITE_KEY) {
20 console.warn('Segment server: SEGMENT_WRITE_KEY not set — event not sent');
21 return;
22 }
23
24 try {
25 const response = await fetch('https://api.segment.io/v1/track', {
26 method: 'POST',
27 headers: {
28 'Authorization': `Basic ${Buffer.from(SEGMENT_WRITE_KEY + ':').toString('base64')}`,
29 'Content-Type': 'application/json',
30 },
31 body: JSON.stringify({
32 ...payload,
33 timestamp: payload.timestamp ?? new Date().toISOString(),
34 }),
35 });
36
37 if (!response.ok) {
38 const text = await response.text();
39 console.error('Segment server track failed:', response.status, text);
40 }
41 } catch (error) {
42 // Never throw — analytics failure should not break business logic
43 console.error('Segment server track error:', error);
44 }
45}
46
47export async function identifyServer(
48 userId: string,
49 traits: Record<string, unknown>
50): Promise<void> {
51 if (!SEGMENT_WRITE_KEY) return;
52 try {
53 await fetch('https://api.segment.io/v1/identify', {
54 method: 'POST',
55 headers: {
56 Authorization: `Basic ${Buffer.from(SEGMENT_WRITE_KEY + ':').toString('base64')}`,
57 'Content-Type': 'application/json',
58 },
59 body: JSON.stringify({ userId, traits, timestamp: new Date().toISOString() }),
60 });
61 } catch (error) {
62 console.error('Segment server identify error:', error);
63 }
64}

Pro tip: Always wrap server-side Segment calls in try/catch and never let analytics failures interrupt business logic. A failed track() call should be logged but should never cause a 500 error that breaks your API response.

Expected result: After deploying to Netlify and setting SEGMENT_WRITE_KEY, server-side events from API routes appear in the Segment Source Debugger. These events are not blocked by ad blockers and fire reliably even if the user closes the browser tab during the operation.

Common use cases

Replace Multiple Analytics SDKs with a Single Segment Integration

Your Bolt app currently has Mixpanel, Google Analytics, and Intercom each requiring their own SDK, initialization, and event tracking calls. Replace all three with a single Segment integration. After the migration, add new analytics tools (Amplitude, Heap, or a data warehouse like BigQuery) directly from the Segment dashboard without any code changes.

Bolt.new Prompt

I want to replace my separate Mixpanel, Google Analytics, and Intercom integrations with a single Segment integration. Remove the existing analytics SDK imports and installations. Install @segment/analytics-next. Create lib/segment.ts that initializes the Analytics client with VITE_SEGMENT_WRITE_KEY. Create an analytics utility that exports identify, track, and page functions using the Segment client. Update my existing event tracking calls to use the new Segment analytics functions.

Copy this prompt to try it in Bolt.new

Build a Typed Event Tracking System for a SaaS App

Use Segment's Protocols feature to enforce a typed event schema across your team. Define your event tracking plan in lib/analytics.ts with TypeScript-typed functions for each event. Every team member calls analytics.checkoutStarted({ plan, price }) instead of track('Checkout Started', { plan, price }), ensuring consistent property names and types across your entire codebase.

Bolt.new Prompt

Create a type-safe analytics tracking module in lib/analytics.ts that wraps Segment's track function. Use TypeScript interfaces to define the exact properties for each event: SignupCompleted { method: string }, CheckoutStarted { plan: string; price: number }, SubscriptionUpgraded { fromPlan: string; toPlan: string; mrr: number }, ProjectCreated { templateUsed: boolean }, FeatureEnabled { featureName: string }. Export typed functions for each event. Import the Segment analytics instance from lib/segment.ts.

Copy this prompt to try it in Bolt.new

Send Server-Side Events After Backend Operations

Some events should be sent from the server after a database operation succeeds — not from the browser, where the user could navigate away before the event fires. Use Segment's HTTP Tracking API from a Next.js API route to send server-side events after payment confirmation, subscription changes, or data imports. Server-side events are more reliable and harder to block with ad blockers.

Bolt.new Prompt

After a successful Stripe payment webhook confirms a subscription was created, send a server-side Segment event from my Next.js API route. In my app/api/webhooks/stripe/route.ts, after the subscription is saved to the database, call Segment's HTTP API to track 'Subscription Created' with the user ID, plan name, and MRR. Use SEGMENT_WRITE_KEY (server-side, no NEXT_PUBLIC_ prefix) and the Segment HTTP Tracking API endpoint.

Copy this prompt to try it in Bolt.new

Troubleshooting

Events do not appear in Segment Source Debugger after calling analytics.track()

Cause: The Write Key may be incorrect, the @segment/analytics-next package may not be initialized before tracking, or the analytics instance returned null because the Write Key environment variable was missing.

Solution: Check that VITE_SEGMENT_WRITE_KEY is set in .env and matches the Write Key from Segment Settings → API Keys → Write Key. Add console.log statements to verify the analytics instance is not null before calling track(). Open Network tab in DevTools and look for requests to api.segment.io — if you see them but they fail, the Write Key is wrong.

typescript
1// Debug: log the analytics instance and first event:
2console.log('Segment analytics instance:', analytics);
3analytics?.track('Debug Test', { test: true }).then(() =>
4 console.log('Segment track promise resolved')
5);

Events arrive in Segment but do not appear in my configured destination (Mixpanel, GA4, etc.)

Cause: The destination may not be enabled, the destination credentials may be incorrect, or the destination may be in filtering mode that excludes your events.

Solution: In Segment dashboard → Connections → your destination, verify it shows 'Enabled'. Check the destination settings for correct credentials (Mixpanel Project Token, GA4 Measurement ID, etc.). Check the Event Delivery tab for the destination — it shows success/failure counts and error messages for forwarded events. Check Destination Filters to ensure your events are not being filtered out.

TypeError: Cannot read properties of null (reading 'track') — analytics is null

Cause: The VITE_SEGMENT_WRITE_KEY environment variable is not set, so the analytics instance in lib/segment.ts initialized to null. The analytics?.track() optional chaining silently fails in this case.

Solution: Verify VITE_SEGMENT_WRITE_KEY is set in your .env file. Restart the Bolt dev server after editing .env — Vite bakes environment variables at startup. Add a console.warn in lib/segment.ts when the key is missing to make the problem visible.

typescript
1// In lib/segment.ts — add a clear warning:
2if (!writeKey) {
3 console.warn(
4 '[Segment] VITE_SEGMENT_WRITE_KEY is not set.\n' +
5 'Analytics events will not be tracked.\n' +
6 'Add VITE_SEGMENT_WRITE_KEY to your .env file.'
7 );
8}

Server-side Segment events from Next.js API routes are missing after deployment

Cause: SEGMENT_WRITE_KEY (server-side) was not added to Netlify or Vercel environment variables, so it is undefined in production.

Solution: In Netlify: Site Settings → Environment Variables → add SEGMENT_WRITE_KEY (without NEXT_PUBLIC_ prefix). Trigger a redeploy. Verify the key is the same as your source's Write Key in Segment Settings.

Best practices

  • Create separate Segment Sources for development and production to keep test events out of your production analytics data
  • Use Title Case for Segment event names ('Subscription Upgraded', not 'subscription_upgraded') — this is Segment's convention and ensures consistent mapping to all destination schemas
  • Wrap server-side Segment calls in try/catch and never let analytics failures interrupt your business logic — analytics is a non-critical side effect
  • Keep SEGMENT_WRITE_KEY as a server-side variable for API route usage and use VITE_SEGMENT_WRITE_KEY or NEXT_PUBLIC_SEGMENT_WRITE_KEY only for browser-side tracking
  • Design your tracking plan before writing code — document each event, its properties, and which destinations should receive it in a spreadsheet first
  • Use Segment's Source Debugger (Connections → your source → Debugger) as your first debugging tool — it shows every event with full payload in real-time
  • Implement identify() immediately after login and reset() on logout to ensure events are attributed to the correct user across sessions and devices

Alternatives

Frequently asked questions

Does @segment/analytics-next work in Bolt.new's WebContainer preview?

Yes. @segment/analytics-next sends events directly from the user's browser to Segment's API over HTTPS — it does not use Bolt's WebContainer server runtime. The SDK works identically in the Bolt preview and production. Verify events arrive by checking the Segment Source Debugger while interacting with your Bolt preview.

Is the Segment Write Key safe to put in client-side code?

Yes, for the browser write key. The Write Key only authorizes writing events to your Segment source — it cannot read your data or access other sources. Use VITE_SEGMENT_WRITE_KEY or NEXT_PUBLIC_SEGMENT_WRITE_KEY for browser-side tracking. If you want to prevent abuse (people spamming fake events with your Write Key), Segment offers Source IP filtering in your source settings.

How is Segment different from just adding Mixpanel and Google Analytics directly?

With direct integrations, you maintain separate SDK installations, initialization code, and event tracking calls for each tool. When you add a new analytics tool, you write more integration code. With Segment, you write one integration and configure destinations in the dashboard — no code changes needed to add or swap analytics tools. Segment also standardizes your event schema across all destinations and provides a central debugging interface.

What happens if Segment is down — do my analytics events get lost?

Segment's @segment/analytics-next SDK queues events locally in the browser if Segment's API is unavailable, then retries delivery automatically when connectivity returns. The retry window is bounded — events older than a few hours may be dropped if Segment remains unreachable. For business-critical events, consider dual-tracking: send the event to both Segment and directly to a critical destination (like your own database) to ensure no data loss.

Can Segment receive events from Bolt.new's WebContainer server runtime?

For server-side events from Next.js API routes, Segment's HTTP Tracking API (a standard HTTPS POST to api.segment.io/v1/track) works from the WebContainer during development since it is an outbound HTTPS call. After deployment to Netlify or Bolt Cloud, server-side events work reliably in a proper Node.js environment. Server-side tracking is recommended for critical conversion events that shouldn't be blockable by ad blockers.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.