#nextjs frontend
1 messages · Page 1 of 1 (latest)
To set up a Next.js frontend with GraphQL, Tailwind CSS, and shadcn/ui, you can follow these steps:
-
Create a new Next.js application with Tailwind CSS for styling:
You can use thecreate-next-appcommand to create a new Next.js application pre-configured with Tailwind CSS.npx create-next-app@latest --tailwind your-app-nameReplace
your-app-namewith the name of your application. source (https://vercel.com/guides/building-ecommerce-sites-with-next-js-and-shopify#setting-up-your-next.js-application) -
Install Tailwind CSS:
Install the Tailwind CSS packages and run theinitcommand to generate both thetailwind.config.jsandpostcss.config.jsfiles:npm install -D tailwindcss postcss autoprefixer npx tailwindcss init -psource (https://nextjs.org/docs/app/building-your-application/styling/tailwind-css)
-
Configure Tailwind CSS:
Insidetailwind.config.js, add paths to the files that will use Tailwind CSS class names:/** @type {import('tailwindcss').Config} */ module.exports = { content: [ './app/**/*.{js,ts,jsx,tsx,mdx}', // Note the addition of the `app` directory. './pages/**/*.{js,ts,jsx,tsx,mdx}', './components/**/*.{js,ts,jsx,tsx,mdx}', // Or if using `src` directory: './src/**/*.{js,ts,jsx,tsx,mdx}', ], theme: { extend: {}, }, plugins: [], }source (https://nextjs.org/docs/app/building-your-application/styling/tailwind-css)
-
Install shadcn/ui:
shadcn/ui is a library of reusable components built using Radix UI and Tailwind CSS. You can install it using npm:npm install @shadcn/uiNote: This command is not directly from the sources provided, but it's the standard way to install npm packages.
- Fetch data from GraphQL API:
After setting up your Shopify store, you can fetch data from Shopify using the GraphQL API. Add your generated Shopify access token as well as the domain for your store to an.env.localfile in your newly created application:source (https://vercel.com/guides/building-ecommerce-sites-with-next-js-and-shopify#setting-up-your-next.js-application)SHOPIFY_STOREFRONT_ACCESS_TOKEN='your-token' SHOPIFY_STORE_DOMAIN='your-store.myshopify.com'