Skip to content

Commit 53f5bb9

Browse files
committed
import vercel/commerce at 694c5c17
1 parent 9aff12e commit 53f5bb9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+5831
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
COMPANY_NAME="Vercel Inc."
2+
TWITTER_CREATOR="@vercel"
3+
TWITTER_SITE="https://nextjs.org/commerce"
4+
SITE_NAME="Next.js Commerce"
5+
SHOPIFY_REVALIDATION_SECRET=""
6+
SHOPIFY_STOREFRONT_ACCESS_TOKEN=""
7+
SHOPIFY_STORE_DOMAIN="[your-shopify-store-subdomain].myshopify.com"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
.playwright
11+
12+
# next.js
13+
/.next/
14+
/out/
15+
16+
# production
17+
/build
18+
19+
# misc
20+
.DS_Store
21+
*.pem
22+
23+
# debug
24+
npm-debug.log*
25+
yarn-debug.log*
26+
yarn-error.log*
27+
.pnpm-debug.log*
28+
29+
# local env files
30+
.env*
31+
!.env.example
32+
33+
# vercel
34+
.vercel
35+
36+
# typescript
37+
*.tsbuildinfo
38+
next-env.d.ts
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Next.js: debug server-side",
6+
"type": "node-terminal",
7+
"request": "launch",
8+
"command": "pnpm dev"
9+
},
10+
{
11+
"name": "Next.js: debug client-side",
12+
"type": "chrome",
13+
"request": "launch",
14+
"url": "http://localhost:3000"
15+
},
16+
{
17+
"name": "Next.js: debug full stack",
18+
"type": "node-terminal",
19+
"request": "launch",
20+
"command": "pnpm dev",
21+
"serverReadyAction": {
22+
"pattern": "started server on .+, url: (https?://.+)",
23+
"uriFormat": "%s",
24+
"action": "debugWithChrome"
25+
}
26+
}
27+
]
28+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"typescript.tsdk": "node_modules/typescript/lib",
3+
"typescript.enablePromptUseWorkspaceTsdk": true,
4+
"editor.codeActionsOnSave": {
5+
"source.fixAll": "explicit",
6+
"source.organizeImports": "explicit",
7+
"source.sortMembers": "explicit"
8+
}
9+
}

examples/vercel-commerce/README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fcommerce&project-name=commerce&repo-name=commerce&demo-title=Next.js%20Commerce&demo-url=https%3A%2F%2Fdemo.vercel.store&demo-image=https%3A%2F%2Fbigcommerce-demo-asset-ksvtgfvnd.vercel.app%2Fbigcommerce.png&env=COMPANY_NAME,SHOPIFY_REVALIDATION_SECRET,SHOPIFY_STORE_DOMAIN,SHOPIFY_STOREFRONT_ACCESS_TOKEN,SITE_NAME,TWITTER_CREATOR,TWITTER_SITE)
2+
3+
# Next.js Commerce
4+
5+
A high-perfomance, server-rendered Next.js App Router ecommerce application.
6+
7+
This template uses React Server Components, Server Actions, `Suspense`, `useOptimistic`, and more.
8+
9+
<h3 id="v1-note"></h3>
10+
11+
> Note: Looking for Next.js Commerce v1? View the [code](https://github.com/vercel/commerce/tree/v1), [demo](https://commerce-v1.vercel.store), and [release notes](https://github.com/vercel/commerce/releases/tag/v1).
12+
13+
## Providers
14+
15+
Vercel will only be actively maintaining a Shopify version [as outlined in our vision and strategy for Next.js Commerce](https://github.com/vercel/commerce/pull/966).
16+
17+
Vercel is happy to partner and work with any commerce provider to help them get a similar template up and running and listed below. Alternative providers should be able to fork this repository and swap out the `lib/shopify` file with their own implementation while leaving the rest of the template mostly unchanged.
18+
19+
- Shopify (this repository)
20+
- [BigCommerce](https://github.com/bigcommerce/nextjs-commerce) ([Demo](https://next-commerce-v2.vercel.app/))
21+
- [Ecwid by Lightspeed](https://github.com/Ecwid/ecwid-nextjs-commerce/) ([Demo](https://ecwid-nextjs-commerce.vercel.app/))
22+
- [Medusa](https://github.com/medusajs/vercel-commerce) ([Demo](https://medusa-nextjs-commerce.vercel.app/))
23+
- [Saleor](https://github.com/saleor/nextjs-commerce) ([Demo](https://saleor-commerce.vercel.app/))
24+
- [Shopware](https://github.com/shopwareLabs/vercel-commerce) ([Demo](https://shopware-vercel-commerce-react.vercel.app/))
25+
- [Swell](https://github.com/swellstores/verswell-commerce) ([Demo](https://verswell-commerce.vercel.app/))
26+
- [Umbraco](https://github.com/umbraco/Umbraco.VercelCommerce.Demo) ([Demo](https://vercel-commerce-demo.umbraco.com/))
27+
- [Wix](https://github.com/wix/nextjs-commerce) ([Demo](https://wix-nextjs-commerce.vercel.app/))
28+
29+
> Note: Providers, if you are looking to use similar products for your demo, you can [download these assets](https://drive.google.com/file/d/1q_bKerjrwZgHwCw0ovfUMW6He9VtepO_/view?usp=sharing).
30+
31+
## Integrations
32+
33+
Integrations enable upgraded or additional functionality for Next.js Commerce
34+
35+
- [Orama](https://github.com/oramasearch/nextjs-commerce) ([Demo](https://vercel-commerce.oramasearch.com/))
36+
- Upgrades search to include typeahead with dynamic re-rendering, vector-based similarity search, and JS-based configuration.
37+
- Search runs entirely in the browser for smaller catalogs or on a CDN for larger.
38+
39+
- [React Bricks](https://github.com/ReactBricks/nextjs-commerce-rb) ([Demo](https://nextjs-commerce.reactbricks.com/))
40+
- Edit pages, product details, and footer content visually using [React Bricks](https://www.reactbricks.com) visual headless CMS.
41+
42+
## Running locally
43+
44+
You will need to use the environment variables [defined in `.env.example`](.env.example) to run Next.js Commerce. It's recommended you use [Vercel Environment Variables](https://vercel.com/docs/concepts/projects/environment-variables) for this, but a `.env` file is all that is necessary.
45+
46+
> Note: You should not commit your `.env` file or it will expose secrets that will allow others to control your Shopify store.
47+
48+
1. Install Vercel CLI: `npm i -g vercel`
49+
2. Link local instance with Vercel and GitHub accounts (creates `.vercel` directory): `vercel link`
50+
3. Download your environment variables: `vercel env pull`
51+
52+
```bash
53+
pnpm install
54+
pnpm dev
55+
```
56+
57+
Your app should now be running on [localhost:3000](http://localhost:3000/).
58+
59+
<details>
60+
<summary>Expand if you work at Vercel and want to run locally and / or contribute</summary>
61+
62+
1. Run `vc link`.
63+
1. Select the `Vercel Solutions` scope.
64+
1. Connect to the existing `commerce-shopify` project.
65+
1. Run `vc env pull` to get environment variables.
66+
1. Run `pnpm dev` to ensure everything is working correctly.
67+
</details>
68+
69+
## Vercel, Next.js Commerce, and Shopify Integration Guide
70+
71+
You can use this comprehensive [integration guide](https://vercel.com/docs/integrations/ecommerce/shopify) with step-by-step instructions on how to configure Shopify as a headless CMS using Next.js Commerce as your headless Shopify storefront on Vercel.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import Footer from 'components/layout/footer';
2+
3+
export default function Layout({ children }: { children: React.ReactNode }) {
4+
return (
5+
<>
6+
<div className="w-full">
7+
<div className="mx-8 max-w-2xl py-20 sm:mx-auto">{children}</div>
8+
</div>
9+
<Footer />
10+
</>
11+
);
12+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import OpengraphImage from 'components/opengraph-image';
2+
import { getPage } from 'lib/shopify';
3+
4+
export const runtime = 'edge';
5+
6+
export default async function Image({ params }: { params: { page: string } }) {
7+
const page = await getPage(params.page);
8+
const title = page.seo?.title || page.title;
9+
10+
return await OpengraphImage({ title });
11+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import type { Metadata } from 'next';
2+
3+
import Prose from 'components/prose';
4+
import { getPage } from 'lib/shopify';
5+
import { notFound } from 'next/navigation';
6+
7+
export async function generateMetadata({
8+
params
9+
}: {
10+
params: { page: string };
11+
}): Promise<Metadata> {
12+
const page = await getPage(params.page);
13+
14+
if (!page) return notFound();
15+
16+
return {
17+
title: page.seo?.title || page.title,
18+
description: page.seo?.description || page.bodySummary,
19+
openGraph: {
20+
publishedTime: page.createdAt,
21+
modifiedTime: page.updatedAt,
22+
type: 'article'
23+
}
24+
};
25+
}
26+
27+
export default async function Page({ params }: { params: { page: string } }) {
28+
const page = await getPage(params.page);
29+
30+
if (!page) return notFound();
31+
32+
return (
33+
<>
34+
<h1 className="mb-8 text-5xl font-bold">{page.title}</h1>
35+
<Prose className="mb-8" html={page.body as string} />
36+
<p className="text-sm italic">
37+
{`This document was last updated on ${new Intl.DateTimeFormat(undefined, {
38+
year: 'numeric',
39+
month: 'long',
40+
day: 'numeric'
41+
}).format(new Date(page.updatedAt))}.`}
42+
</p>
43+
</>
44+
);
45+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { revalidate } from 'lib/shopify';
2+
import { NextRequest, NextResponse } from 'next/server';
3+
4+
export async function POST(req: NextRequest): Promise<NextResponse> {
5+
return revalidate(req);
6+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'use client';
2+
3+
export default function Error({ reset }: { reset: () => void }) {
4+
return (
5+
<div className="mx-auto my-4 flex max-w-xl flex-col rounded-lg border border-neutral-200 bg-white p-8 md:p-12 dark:border-neutral-800 dark:bg-black">
6+
<h2 className="text-xl font-bold">Oh no!</h2>
7+
<p className="my-2">
8+
There was an issue with our storefront. This could be a temporary issue, please try your
9+
action again.
10+
</p>
11+
<button
12+
className="mx-auto mt-4 flex w-full items-center justify-center rounded-full bg-blue-600 p-4 tracking-wide text-white hover:opacity-90"
13+
onClick={() => reset()}
14+
>
15+
Try Again
16+
</button>
17+
</div>
18+
);
19+
}

0 commit comments

Comments
 (0)