惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
Cisco Blogs
Cyberwarzone
Cyberwarzone
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
SecWiki News
SecWiki News
Martin Fowler
Martin Fowler
T
Tor Project blog
N
Netflix TechBlog - Medium
C
Cybersecurity and Infrastructure Security Agency CISA
V
Vulnerabilities – Threatpost
V
Visual Studio Blog
GbyAI
GbyAI
PCI Perspectives
PCI Perspectives
D
DataBreaches.Net
Jina AI
Jina AI
H
Heimdal Security Blog
云风的 BLOG
云风的 BLOG
P
Privacy International News Feed
A
About on SuperTechFans
J
Java Code Geeks
美团技术团队
H
Hackread – Cybersecurity News, Data Breaches, AI and More
N
News | PayPal Newsroom
有赞技术团队
有赞技术团队
MyScale Blog
MyScale Blog
博客园 - 司徒正美
C
Check Point Blog
T
Threat Research - Cisco Blogs
Attack and Defense Labs
Attack and Defense Labs
宝玉的分享
宝玉的分享
AI
AI
Simon Willison's Weblog
Simon Willison's Weblog
C
Cyber Attacks, Cyber Crime and Cyber Security
I
Intezer
P
Proofpoint News Feed
Blog — PlanetScale
Blog — PlanetScale
Apple Machine Learning Research
Apple Machine Learning Research
Hugging Face - Blog
Hugging Face - Blog
The Last Watchdog
The Last Watchdog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Vercel News
Vercel News
I
InfoQ
阮一峰的网络日志
阮一峰的网络日志
Cisco Talos Blog
Cisco Talos Blog
W
WeLiveSecurity
Hacker News: Ask HN
Hacker News: Ask HN
Recent Commits to openclaw:main
Recent Commits to openclaw:main
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
D
Docker
博客园 - Franky
Security Archives - TechRepublic
Security Archives - TechRepublic

Vercel News

Vercel Open Source Program: Winter 2026 cohort How Notion Workers run untrusted code at scale with Vercel Sandbox How we run Vercel's CDN in front of Discourse From idea to secure checkout in minutes with Stripe Building Slack agents can be easy Scaling redirects to infinity on Vercel Advancing Python typing Gamma builds design-first agents with Vercel How Avalara turns pipe dreams into patent-pending with v0 Keeping community human while scaling with agents How OpenEvidence built a healthcare AI that physicians actually trust Security boundaries in agentic architectures Skills Night: 69,000+ ways agents are getting smarter Video Generation with AI Gateway We Ralph Wiggumed WebStreams to make them 10x faster How Stably ships AI testing agents in hours, not weeks How we built AEO tracking for coding agents Anyone can build agents, but it takes a platform to run them Introducing Geist Pixel The Vercel AI Accelerator is back with $6m in credits Making agent-friendly pages with content negotiation The Vercel OSS Bug Bounty program is now available Introducing the new v0 Run untrusted code with Vercel Sandbox, now generally available How Stripe built a game-changing app in a single flight with v0 How Sensay went from zero to product in six weeks AGENTS.md outperforms skills in our agent evals Agent skills explained: An FAQ Testing if "bash is all you need" AWS databases are now live on the Vercel Marketplace and v0 Use Perplexity Web Search with Vercel AI Gateway Introducing: React Best Practices Nick Bogaty joins Vercel as Chief Revenue Officer How Mux shipped durable video workflows with their @mux/ai SDK How to build agents with filesystems and bash How we made v0 an effective coding agent Stopping the slow death of internal tools Building AI-Generated Pixel Trading Cards with Vercel AI Gateway We removed 80% of our agent’s tools AI SDK 6 Our $1 million hacker challenge for React2Shell Cline now runs on Vercel AI Gateway How to prompt v0 Build smarter workflows with Notion and v0 Vercel launches partner certification Inside Workflow DevKit: How framework integrations work React2Shell Security Bulletin | Vercel Knowledge Base Billions of requests: Black Friday-Cyber Monday 2025 Investing in the Python ecosystem AWS Databases coming to the Vercel Marketplace How we built the v0 iOS app Workflow Builder: Build your own workflow automation platform Vercel Open Source Program: Fall 2025 cohort Self-driving infrastructure Vercel collaborates with Google for Gemini 3 Pro Preview launch Vercel: The anti-vendor-lock-in cloud How Nous Research used BotID to block automated abuse at scale How AI Gateway runs on Fluid compute What we learned building agents at Vercel Build and deploy data applications on Snowflake with v0 BotID Deep Analysis catches a sophisticated bot network in real-time Vercel achieves TISAX AL2 compliance to serve automotive partners Bun runtime on Vercel Functions David Totten Joins Vercel to Lead Global Field Engineering Vercel Ship AI 2025 recap You can just ship agents AI agents and services on the Vercel Marketplace Built-in durability: Introducing Workflow Development Kit Zero-config backends on Vercel AI Cloud Introducing Vercel Agent: Your new Vercel teammate Update regarding Vercel service disruption on October 20, 2025 Agents at work, a partnership with Salesforce and Slack Running Next.js in ChatGPT: How to Build ChatGPT Apps Talha Tariq joins Vercel as CTO of Security Just another (Black) Friday Server rendering benchmarks: Fluid Compute and Cloudflare Workers Towards the AI Cloud: Our Series F Collaborating with Anthropic on Claude Sonnet 4.5 to power intelligent coding agents Preventing the stampede: Request collapsing in the Vercel CDN BotID uncovers hidden SEO poisoning How we made global routing faster with Bloom filters What you need to know about vibe coding Scale to one: How Fluid solves cold starts Addressing security & quality issues with MCP tools - Vercel AI agents at scale: Rox’s Vercel-powered revenue operating system Agentic Infrastructure Zero Data Retention on AI Gateway Optimizing Vercel Sandbox snapshots How Waldium made a blog platform work for humans and AI alike How FLORA shipped a creative agent on Vercel's AI stack Agent responsibly Making Turborepo 96% faster with agents, sandboxes, and humans Unified reporting for all AI Gateway usage new.website joins forces with v0 SERHANT.'s playbook for rapid AI iteration Two startups at global scale without DevOps Chat SDK brings agents to your users 360 billion tokens, 3 million customers, 6 engineers Meet the 2026 Vercel AI Accelerator Cohort Build knowledge agents without embeddings
Next.js Commerce: A headless Shopify ecommerce template built with the App Router - Vercel – Vercel
2023-08-07 · via Vercel News

6 min read

Today, we’re excited to introduce Next.js Commerce 2.0.

  • App Router Ready: Using React Server Components, Server Actions, built-in layouts, metadata, and all the new patterns from the recently released App Router.

  • Dynamic Storefront: A dynamic storefront at the speed of static. Customize content without sacrificing performance.

  • Simplified Architecture: Next.js Commerce is now a single provider per repository, resulting in less code and fewer abstractions for your application.

Our new ecommerce accelerator template showcases the best patterns for building composable commerce applications, including support for BigCommerce, Medusa, Saleor, Shopify, and Swell.

View the demo or deploy your own version today.

Link to headingWhy is building an ecommerce site difficult?

When Google announced that page experience would be a ranking factor in search results and Amazon found that just 100 milliseconds of extra load time cost them 1% in sales, it put a lot of pressure on ecommerce sites to raise the bar or suffer the consequences.

However, according to the Web Almanac, ecommerce sites still struggle to achieve good performance.

Web Almanac's 2021 Median Lighthouse scores for e-commerce sites on mobileWeb Almanac's 2021 Median Lighthouse scores for e-commerce sites on mobile

Web Almanac's 2021 Median Lighthouse scores for e-commerce sites on mobile

Commerce sites are more complex than they seem on the surface. What is it about ecommerce that contributes to these metrics?

  • They make lots of page requests. The 50th percentile of all ecommerce sites had 101 requests on the homepage on mobile. That seems like a lot, but think of all the product and sale information that appears on most home pages.

  • They are asset heavy. Video and Images are the first and second most requested resource type as well as the first and second largest contributor to page weight. Once again, think of all the product and sale imagery you see on the homepage alone.

  • They focus on personalization. This includes recommended products based on your shopping history and habits or location, items in your cart, user information, and more.

Many commerce platforms come with pre-built templates to help you get started quickly, but they often lack the rigor needed to scale and perform at a high level.

For example, Shopify’s store themes only require a minimum average Lighthouse performance score of 60 across the theme's product, collection, and home page, for both desktop and mobile.

Sanity Toolkit for Next.js

Achieve next-level ecommerce speed with Sanity's enhanced Next.js toolkit—tailored to developers and designed for optimal user experiences.

Learn more

Large retailers such as Under Armour, Walmart, Target, Nike, and more trust their ecommerce experience to Next.js to help them achieve better results. Let’s look at how.

Link to headingNext.js Commerce v1

The first version of Next.js Commerce was announced during Next.js Conf 2020 and alongside Next.js 10. Newer Next.js features at the time, like next/image with its automatic image optimization and static and dynamic rendering on a per-page basis, provided the ingredients to create a better ecommerce experience.

Paired with the industry shift from monoliths to headless ecommerce, we were able raise the bar for ecommerce sites. Next.js Commerce embodied a best-in-class, highly performant, highly optimized commerce experience including excellent web core vitals, SEO optimizations, Incremental Static Regeneration, link prefetching, and more.

This version of Next.js Commerce was as tremendous step forward, but there was still room for improvement for highly dynamic ecommerce sites.

Link to headingNext.js Commerce 2.0—dynamic storefronts at the speed of static

There are many dynamic elements in commerce to consider such as a user’s cart, search results, products being purchased and affecting availability, product recommendations, and more.

Even with advancements in Server-Side Rendering (SSR), Static Site Generation (SSG), and Incremental Static Regeneration (ISR), creating an ecommerce site was still a difficult task.

In order to be the most effective, we need something more granular to control the static and dynamic parts of our application. This is where Next.js and the introduction of the App Router gives you access to a deeper level of control, allowing you to create storefronts that feel static, but are completely dynamic.

Link to headingPerformance results

By leveraging the Next.js App Router's latest features and Vercel’s Frontend Cloud, Next.js Commerce 2.0 is able to achieve incredible performance, demonstrating dynamic at the speed of static.

When we shared an early preview, a few remarked that the performance of the site felt static. We had to clarify this is a dynamic, server-rendered storefront that performs at the level of a statically cached page. This is possible due to the new caching architecture in Next.js App Router and the Vercel Data Cache.

To compliment this new release, we also did a minor redesign to give the theme a fresh, modern look.

Let's walkthrough some Next.js features that made this possible.

Link to headingLayouts and pages

App Router introduces a new file name routing convention, which includes layouts and pages. This allows you to create and share site wide layouts and components, like headers and footers, but specifically for ecommerce, this allows you to create a cart that is accessible from anywhere on the site. The overall experience is much snappier. This was possible before, but is now more easier to achieve.

Link to headingReact Server Components, Streaming, and Suspense

React Server Components (RSCs) allow us to do as much work on the server as possible, including dynamic API calls, before returning a fully rendered UI. This means a leaner client-side JavaScript bundle size and fewer client-side requests. This also means no layout shift, no loading spinners, and a faster time to interactive.

Paired with Streaming with Suspense, we can prioritize and return portions of the UI as they are ready instead of waiting for the entire page to be ready. This gives users content faster. Your site is no longer as slow as your slowest backend. Portions of the site below the fold can be streamed in later, while users see more immediate content above the fold.

  • The layout, page, header, and search sort filters are all rendered on the server available on initial page load.

  • The cart, search categories, products, and footer use Suspense independently load when each piece ready.

Link to headingData fetching and caching

The biggest mental model shift in the App Router is to stop thinking which pages should be static or dynamic and starting thinking about what data is static or dynamic. Moving the static and dynamic decisions to data fetching gives you more control over when and where to serve static or dynamic content.

Using the new data fetching and caching paradigms, revalidation (also known as Incremental Static Regeneration) moves to individual fetching too.

We're using Shopify's Storefront API, which utilizes GraphQL. GraphQL expects that all requests are POST requests. We mimic Next.js built-in functionality of caching all calls by default, except for mutations.

lib/shopify/index.ts

const domain = `https://${process.env.SHOPIFY_STORE_DOMAIN!}`;

const endpoint = `${domain}${SHOPIFY_GRAPHQL_API_ENDPOINT}`;

const key = process.env.SHOPIFY_STOREFRONT_ACCESS_TOKEN!;

export async function shopifyFetch({

cache = 'force-cache',

headers,

query,

tags,

variables

}) {

const result = await fetch(endpoint, {

method: 'POST',

headers: {

'Content-Type': 'application/json',

'X-Shopify-Storefront-Access-Token': key,

...headers

},

body: JSON.stringify({

...(query && { query }),

...(variables && { variables })

}),

cache,

...(tags && { next: { tags } })

});

const body = await result.json();

if (body.errors) {

throw body.errors[0];

}

return {

status: result.status,

body

};

}

Shopify fetch wrapper

Since all data is cached by default, we need a way to trigger revalidation of data when needed. Let's use products as an example.

When we update a product description, inventory, etc. in Shopify, we want the site to reflect that change. We also don't want the site make unnecessary calls for this data if it's not changing. So we can cache by default, but add a revalidation tag.

lib/shopify/index.ts

import { getProductQuery } from './queries/product';

const res = await shopifyFetch({

query: getProductQuery,

tags: ['products'],

variables: {

handle: 'acme-t-shirt'

}

});

Get a Shopify product specifying a revalidation tag

Now we can subscribe to Shopify webhooks to be notified when product data changes and we can revalidate the product data using revalidateTag.

app/api/revalidate/route.ts

import { revalidateTag } from 'next/cache';

import { NextRequest, NextResponse } from 'next/server';

export async function POST(req) {

const productWebhooks = ['products/create', 'products/delete', 'products/update'];

const topic = headers().get('x-shopify-topic') || 'unknown';

const isProductUpdate = productWebhooks.includes(topic);

if (!isProductUpdate) {

// We don't need to revalidate anything for any other topics.

return NextResponse.json({ status: 200 });

}

if (isProductUpdate) {

revalidateTag('products');

}

return NextResponse.json({ status: 200, revalidated: true, now: Date.now() });

}

Revalidate products and collections using Shopify webhooks

Link to headingServer Actions

With Server Actions, we can colocate server-side data mutations with the UI that is invoking them, eliminating the need to create API routes used only by your application and reducing client-side JavaScript making the bundle size smaller.

components/cart/add-to-cart.tsx

'use client';

import { addItem } from 'components/cart/actions';

import { useRouter } from 'next/navigation';

import { useTransition } from 'react';

export function AddToCart({selectedVariantId}) {

const router = useRouter();

const [isPending, startTransition] = useTransition();

return (

<button

aria-label="Add item to cart"

disabled={isPending}

onClick={() => {

startTransition(async () => {

const error = await addItem(selectedVariantId);

if (error) {

alert(error);

return;

}

router.refresh();

});

}}

>

'Add To Cart'

</button>

);

}

Next.js Commerce add to cart button

components/cart/actions.ts

'use server';

import { addToCart, createCart, getCart } from 'lib/shopify';

import { cookies } from 'next/headers';

export const addItem = async (variantId) => {

let cartId = cookies().get('cartId')?.value;

let cart;

if (cartId) {

cart = await getCart(cartId);

}

if (!cartId || !cart) {

cart = await createCart();

cartId = cart.id;

cookies().set('cartId', cartId);

}

if (!variantId) {

return new Error('Missing variantId');

}

try {

await addToCart(cartId, [{ merchandiseId: variantId, quantity: 1 }]);

} catch (e) {

return new Error('Error adding item', { cause: e });

}

};

Next.js Commerce add to cart button Server Action

Link to headingRepository strategy

The previous architecture of Next.js Commerce v1 was a multi-vendor, interoperable solution, including integrations with ten e-commerce providers. For v2, we removed roughly 145,000 lines of code making the project more straightforward, maintainable, and easier to understand while also highlighting the latest features of the Next.js App Router.

Providers are able to fork the Next.js Commerce repository add support for their platform. We’re delighted that our partners BigCommerce, Medusa, Saleor, and Swell have embraced this new vision and already have templates and demos using Next.js Commerce 2.0 ready to go. If you want to add support for your platform, follow the instructions and open a pull request to add yours to the list.

To get started with your own ecommerce store, you can deploy your own version of Next.js Commerce 2.0 + Shopify by visiting the template page and using our one click to deploy button.