E-commerce with

In this first episode of Nextjs and Directus series we are going to set everything up and fetch some data to see if everything is working properly.
You guys seemed to like my last video about #Directus 9, and many of you reached out and asked for more Directus 9 content. So I decided to make it a series where we will be using Directus 9 as our API and CMS, and of course Nextjs for the frontend of our site. Kind of like we did with Strapi and #Nextjs series.
This time however we will add #Tailwind into the mix and also include React Query right from the start for better performing API requests, caching, state management and so on. Oh, and also instead of using #REST API we are going to use #GraphQL for this series.
Also I can't think of a better time to start this series, Vercel just released Nextjs 12, which brought with it some major changes and improvements to the framework, Directus is still in Beta or Release Candidate phase, much has changed on that front from the latest video so this would be a great time to check everything out.
The goal of this series is to create a website and publish it online, we will be using Digital Ocean for that. And also near the end of the series I'm going to show you how to implement automatic deployments using Github Actions. Just like I did for my website.
But before all that we have to start somewhere, the goals for this episode will be:
- Installing Directus 9
- Next.js
- Tailwind
- React Query
- Creating a collection in Directus 9 and display it on page with GraphQL
Code used in this video
bit.ly/31hZtCR
----------------------------------------------------------------------------------------------
⭐ Kite is a free AI-powered coding assistant that will help you code faster and smarter. The Kite plugin integrates with all the top editors and IDEs to give you smart completions and documentation while you’re typing. You can check it out here: bit.ly/3qdjIc5​​​​​
------------------------------------------------------------------------------------------------
You can support my work on Patreon
/ watchlearn
Follow me on Social Media
Github: github.com/ivandoric
Twitter: / ivan_doric
Instagram: / watchlearntuts
Facebook: / watchlearntutorials

Пікірлер: 92

  • @WatchandLearnTutorials
    @WatchandLearnTutorials2 жыл бұрын

    If you are getting CORS errors with this setup please follow this link: bit.ly/3JX9kPi

  • @loveillusionist5299

    @loveillusionist5299

    2 жыл бұрын

    I am getting error GRAPHQL_VALIDATION_EXCEPTION Cannot query field "featured_image" on type "posts".

  • @loveillusionist5299

    @loveillusionist5299

    2 жыл бұрын

    also how do you delete field on directus?

  • @loveillusionist5299

    @loveillusionist5299

    2 жыл бұрын

    for anyone else who is experiencing the same issue you must expand featured image and select the subfield id featured_image { id } and also pass an "access_token" with view permissions for directus files or give permissions to public still not sure why this is because i can query the "featured_image" field with rest api without directus file permissions

  • @loveillusionist5299

    @loveillusionist5299

    2 жыл бұрын

    and to delete field you just had to scroll down on the dropdown i feel like an idiot

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    @@loveillusionist5299 Glad you solved it 😀

  • @ninogjoni
    @ninogjoni2 жыл бұрын

    Directus is true opensource (GPL-3) and they have a very active development team and community! It’s also good to mention that Directus is just an independent layer of your underlying database, so your database schema will remain pristine!

  • @dudiyalov
    @dudiyalov2 жыл бұрын

    This was a great tutorial , I got so lost trying other videos but this video set me on straight . I will continue to learn from your videos . Thank you so much

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    Great, glad you liked the video 😀

  • @neeshsamsi
    @neeshsamsi2 жыл бұрын

    This is quite literally the entire stack I wanted to learn. I've been struggling trying to get into each technology separately and going down rabbit holes. This is literally everything i need from getting started to deployment. Insane value. Thank you so much

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    Glad I could help, and thanks for watching 😀

  • @cmdaltctr
    @cmdaltctr2 жыл бұрын

    Thank you for this, more please :) Very eager to learn.

  • @ivanbarta2821
    @ivanbarta28212 жыл бұрын

    I'm learning graphQL quickly so I can follow this tutorial. Good job 👍

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    Thanks and thanks for watching 😀

  • @RuudvanZuidam
    @RuudvanZuidam2 жыл бұрын

    Nice looking forward to this one

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    Thanks 😀

  • @everyhandletaken
    @everyhandletaken2 жыл бұрын

    There is only 1 thing I like more than Directus & that is your accent. Great video, thank you!

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    Heh, thanks. never got the accent compliment, everyone just thinks I'm Russian 😀 ... I'm not.

  • @everyhandletaken

    @everyhandletaken

    2 жыл бұрын

    @@WatchandLearnTutorials I would have guessed the same, sorry! 😂 In any case, it’s a pleasure following along & look forward to more great content - hopefully on low-code tools like Directus, such as Amplication, Lowdefy or others 🤞🏻

  • @pathakvivek7865
    @pathakvivek78652 жыл бұрын

    Yess... Please upload next episode very soon..

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    I will try. 👍

  • @benyamynbrkyc
    @benyamynbrkyc2 жыл бұрын

    Great Video Ivan!

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    Thanks 👍

  • @NewwebmasterRu
    @NewwebmasterRu2 жыл бұрын

    Каждый раз меня удивляет это парень. Так держать!

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    Thanks 😀

  • @isagive
    @isagive2 жыл бұрын

    As always - you are awesome man ❤️❤️ Please small humble comment: i think it would really help to see file structure on left / right. Trying to understand where you are, inside what folder etc is sometimes confusing.

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    Thanks 😀 ... Checkout the last video in this series, or the one before it. I tried to make folder structure a bit clearer there. I realise that sometimes it can be confusing.

  • @techstack1042
    @techstack10422 жыл бұрын

    It would be very helpful if u show how to add custom api endpoint and custom api hook completely...

  • @photocracker100
    @photocracker1002 жыл бұрын

    Thank you very much for the video! This is the most sensible video on this topic! Please tell me when to wait for the continuation? This month? :)

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    There will be a video this week probably.

  • @L1phful
    @L1phful2 жыл бұрын

    Awesome video! Can you maybe show us how to make flexible content like content elements for pages? For example Imagetext, gallery and then add it to a CMS page? Probably with a many to many relationship?

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    Probably not. Sorry.

  • @rrAzz
    @rrAzz2 жыл бұрын

    Sweet!

  • @marklong2060
    @marklong2060 Жыл бұрын

    Had to remove the , { variables: {} = {} } from fetchData and queries.js because it was throwing a reference error.

  • @beeb7006
    @beeb70062 жыл бұрын

    Thanks for the video! Could you make also a video about how to acces data from the database in a custom API endpoint (in directus)? Would really really appriciate that!

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    When accessing API you are accessing data from database already. So you actually wanna see how to create custom endpoints... is that corect?

  • @beeb7006

    @beeb7006

    2 жыл бұрын

    @@WatchandLearnTutorials Yes. I would really appriciate that!

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    @@beeb7006 Ok, I will try to make an episode about it.

  • @philipplohner5646
    @philipplohner56462 жыл бұрын

    Many Thanks!

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    Thanks for watching 😀

  • @jawadbinsarfraz832
    @jawadbinsarfraz8329 ай бұрын

    Will it possible to integrate Directus with NEST js ?

  • @chalwaz9192
    @chalwaz91922 жыл бұрын

    Great! have you tried getting dynamic zones (from strapi) functionality from directus, they say it can be achievable using many to any relationship. Can you put some light on it? second what about the graphql playground, writing manual queries can be a nightmare and hard to debug.

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    As for dynamic zones - I don't know what that is TBH. So I can't put some light on it. We are going to install graphQL playground in the next episode which should be coming this week, so stay tuned.

  • @yanfriskantoni
    @yanfriskantoni2 жыл бұрын

    What about any methods to, as an example, filter our list of data? It's like what OctoberCmS do with listExtendQuery($query). Can't found any documentation about it, except to write our own extensions.

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    I don't know. Haven't gotten that deep yet.

  • @adolfusadams4615
    @adolfusadams46152 жыл бұрын

    1) Can Directus convert uploaded jpg, png etc images to the webp format? If so, can you show how? 2) When installing Directus instead of using a local database, it is possible to connect it to a cloud database, e.g. Hasura Cloud? If possible, can you also show how?

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    1. Not that I'm aware of. However you can use Next.js Image component and it will automatically serve your images in webp format if the browser supports it. 2. I don't think it's possible at the moment.

  • @bastienetienne778
    @bastienetienne7782 жыл бұрын

    tailwind config change : tailwindcss.com/docs/upgrade-guide#migrating-to-the-jit-engine

  • @mediacreatif
    @mediacreatif2 жыл бұрын

    Hello. Do you use Babel or Rust in this course ? I had to configure back to Babel with a .babelrc file because I had some errors on VSCODE, do you know how to deal with that please ?

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    We are using Rust, since the app is made with Next 12 and it's using Rust by default. I don't know how to deal with VSC errors because I don't use VSC. Better ask on Stack Overflow or on Next forums. Although this seems strange, and it probably doesn't have to do with VS Code specifically. Maybe try changing your Node version to 14.7. That is the only thing I can think of.

  • @mehdiyahiacherif2326
    @mehdiyahiacherif23262 жыл бұрын

    Directus is awsome , i tried it and then used strapi , for me they are almost the same product , but strapi has more support so idk what to choose

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    They are pretty similar, yes. However Directus is much nicer to use IMO.

  • @ninogjoni

    @ninogjoni

    2 жыл бұрын

    Directus is true opensource (GPL-3) and they have a very active development team and community! It’s also good to mention that Directus is just an independent layer of your underlying database, so your database schema will remain pristine!

  • @mediacreatif
    @mediacreatif2 жыл бұрын

    With Tailwind 3, you don't have to use "mode: 'jit'" anymore, it's included directly.

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    Yeah I know... we did that in one of the episodes.

  • @mediacreatif

    @mediacreatif

    2 жыл бұрын

    @@WatchandLearnTutorials did you make an update to TailwindCSS 3 ? if yes, can you give me the link to the video part ?

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    @@mediacreatif Here you go: kzread.info/dash/bejne/amaJz6ezoLnIXcY.html

  • @mediacreatif

    @mediacreatif

    2 жыл бұрын

    @@WatchandLearnTutorials thank you so much

  • @evivox
    @evivox2 жыл бұрын

    Criminal Minds :)

  • @taunado
    @taunado Жыл бұрын

    What's an alt cmd for 'mkdir' ?

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    Жыл бұрын

    It's Fish shell, it does that automatically.

  • @mediacreatif
    @mediacreatif2 жыл бұрын

    it seems that you used Tailwind 2 in this course. But when I checked your package.json from github, you have a V3.... I'm confused.

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    You need to checkout all the episodes in the series then it will be clear 😀 ... we update to Tailwind 3.0 in one of the episodes.

  • @mediacreatif

    @mediacreatif

    2 жыл бұрын

    @@WatchandLearnTutorials excuse me sir ;)

  • @domjag600
    @domjag6002 жыл бұрын

    Interesting I can query top level no problem but when I query the image.featured_image.id as in your example it breaks. I wonder if something has changed since this video?

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    Did you set all of your permissions correctly? Check if that is inline with what I show in the video.

  • @domjag600

    @domjag600

    2 жыл бұрын

    @@WatchandLearnTutorials It was strange kept getting a graphql error only on the image. I went back, reinstalled graphql and started from scratch-it is working now so not sure where I screwed up possibly when I setup the env.local for graphql. On another note how performant would Directus be with larger datasets?

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    @@domjag600 I have no idea. They say that Directus API is very fast, 10 times faster than old Directus 8 API which was built on top of Laravel. So I'm guessing it would be pretty fast, but of course this depends on a lot of stuff like your DB server, your hosting for the app etc.

  • @MrJfergs

    @MrJfergs

    Жыл бұрын

    same problem here I had the issue ""Field \"featured_image\" must not have a selection since type \"String\" has no subfields." for no reason

  • @dilkashshaikhmahajan1185
    @dilkashshaikhmahajan11852 жыл бұрын

    { "errors": [ { "message": "Collection \"HomePage\" already exists.", "extensions": { "code": "INVALID_PAYLOAD" } } ] } i got this type error

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    Would help if you also included the code that produced this error.

  • @domjag600
    @domjag6002 жыл бұрын

    When I installed Next and tailwind it automatically installed it with typescript - is that by default?

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    Turns out it is. That wasn't the case when starting the series. If you wanna set it up without TypeScript then install Nextjs manually and add Tailwind manually. By following this guide: tailwindcss.com/docs/guides/nextjs

  • @domjag600

    @domjag600

    2 жыл бұрын

    Zdravo Ivan, Yes that's what I did thanks!

  • @bjmbassahak5398
    @bjmbassahak53982 жыл бұрын

    Please the second part. Please please.

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    Ummm, ok, here you go 😀 : kzread.info/dash/bejne/Y2F8sLaimaXOnag.html

  • @brianronin505
    @brianronin505 Жыл бұрын

    wich is your IDE?

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    Жыл бұрын

    PHP Storm

  • @magicnightcn
    @magicnightcn2 жыл бұрын

    And tailwind just upgraded to 3.0

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    I updated it in the latest episode of this series.

  • @user-oh9jc1nl9k
    @user-oh9jc1nl9k Жыл бұрын

    {"errors":[{"message":"You don't have permission to access this.","extensions":{"code":"FORBIDDEN"}}]} I'm still getting error after I set public permission to read only for my product schema. (localhost:8055/items/product)

  • @mediacreatif
    @mediacreatif2 жыл бұрын

    I have an issue when trying to console.log the hompepageposts : Access to fetch at 'localhost:8055/graphql' from origin 'localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. Can you help me to fix that ? Thanks a lot.

  • @mediacreatif

    @mediacreatif

    2 жыл бұрын

    Ok i found the solution. In your Directus version, the default value of CORS_ENABLED is set to TRUE. But in the last version, it is FALSE. So I needed to set it to TRUE in the "api/.env" file.

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    @@mediacreatif Yup!

  • @mohammadidrus1532
    @mohammadidrus15322 жыл бұрын

    thanks for the video. but I have an CORS issue when fetching the data in my local. "Access to fetch at 'localhost:8055/graphql' from origin 'localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled." any idea to solve this issue?

  • @ivan747

    @ivan747

    2 жыл бұрын

    Just add CORS_ENABLED="true" to the .env file.

  • @mohammadidrus1532

    @mohammadidrus1532

    2 жыл бұрын

    @@ivan747 thanks, It's works now

  • @rajivprasad5994

    @rajivprasad5994

    2 жыл бұрын

    Not working for me.

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    @@rajivprasad5994 Did you add it to the .env file of your Directus app, and not your Nextjs app?

  • @amerispunk

    @amerispunk

    2 жыл бұрын

    @@WatchandLearnTutorials I still have CORS error even after the .env fix. Maybe there's a change in NextJS causing this as well? Help?