Nuxt Commerce

R
Renaudil y a 2 jours
0

Description

Starter kit for high-performance commerce with Nuxt.

npx boilerapp nuxt-commerce

文档

Nuxt Commerce

A high-performance, server-rendered E-commerce app built with Nuxt & Shopify (Demo).

This template uses Nuxt UI, Image & Scripts optimization, Hybrid Rendering, SEO and more.

<details> <summary>Features</summary>

Nuxt Commerce comes with several useful features out of the box:

  1. Nuxt UI - A UI Library for Modern Web Apps.
  2. GraphQL Client - Minimal GraphQL Client + Code Generation
  3. Image Optimization - Resize and transform your images using built-in optimizer or your favorite images CDN
  4. Scripts - Load third-party scripts with better performance, privacy, security and DX
  5. Hybrid rendering - Set different caching rules and rendering modes per route using Route Rules
  6. SEO - Simple configuration for Sitemap.xml, Robots.txt, Meta, and OG Images
  7. JSON-LD - Lightweight Linked Data format for products
</details>

Start here

You will need to use the environment variables defined in .env.example to run Nuxt Commerce.

Note: You should not commit your .env file or it will expose secrets that will allow others to control your Shopify store.

pnpm install
copy .env.example .env
pnpm run dev

Your app should now be running on localhost:3000.

You can also inspect production build like so:

pnpm run build
pnpm run preview

Integrations

If you wish to add an integration with 3rd Party service like Content Management System, Search Engine, or Payment Provider, you can do so by using the regular Nuxt module approach.

Create a new folder in the modules directory named as your integration (i.e storyblok) and inside of it, and index.ts file.

<details> <summary>Why this approach?</summary>

Normally, you could just install the modules and plugins directly inside the global nuxt.config.ts but as your application grows, it could become much harder to maintain the project. By following the modules approach defined by Nuxt you can easily extract domain code into separate module that wraps components, composables, types, and overall integration configuration

</details>

Adding a new integration

If your integration already has a Nuxt module existing, you can import it like shown below. In this file, you can also add integration specific code like components, composables, pages, and enable auto import for them.

// modules/storyblok/index.ts

export default defineNuxtModule({
  meta: {
    name: 'storyblok',
  },
  async setup() {
    const { resolve } = createResolver(import.meta.url)
    addComponentsDir({
      path: resolve('components'), // enable auto import for components/composables/types
    })

    await installModule('@storyblok/nuxt', {
      accessToken: '<YOUR_API_KEY>',
      componentsDir: '~/components',
      // more configuration options
    })
  },
})

Check out the full integration example here

In case of funcionality that does not have a Nuxt module yet, instead of installModule function, you would need to write a custom plugin youself.

E-Commerce Platform

By default, Nuxt Commerce works with Shopify as the E-Commerce Platform but you can use different platforms as well such as Medusa. To do so, you would need to create a custom integration by following thse steps:

  1. Create a new folder in modules directory
  2. In this folder, create a new index.ts file where the e-commerce backend code will be.
  3. In this file, write integration code by using following example:
// modules/medusa/index.ts

export default defineNuxtModule({
  meta: {
    name: "medusa\

Prix

Gratuit

FREE

评论 (0)

常见问题

常见问题解答 (FAQ)

有问题?我们有答案。如果您找不到想要的答案,请随时联系我们。

Boilerapp 是一个专门用于分享 Boilerplates、入门套件(Starter Kits)和项目模版的开发者社区平台。我们的目标很简单:为您节省初始配置(Setup)的时间,让您可以专注于真正重要的代码。无论您是在寻找简单的代码库还是完整的 SaaS 项目,都能在这里找到。

还有其他问题?

我们的团队随时为您提供帮助。联系我们,我们将尽快回复。