Build a Headless WordPress Site with Next.js and WPGraphQL

Поділитися
Вставка
  • Опубліковано 14 гру 2024

КОМЕНТАРІ • 82

  • @tedspens
    @tedspens Рік тому +3

    No fluff, no bells and whistles, no captivating personality (nothing personal 😁), just straight forward, step by step instructions. I wish every instructor would follow this format. My issue was getting data to dynamic pages. Thanks to you, I finally have it working. Thank you!
    On a side note, I'm using SvelteKit and ideally will apply what I learned here. But I might just save myself a lot of headache and stick to NextJS. Anyway, thanks again. Subscribed! 👍

    • @WPEngineBuilders
      @WPEngineBuilders  Рік тому +1

      If we get a subscription despite my non-captivating personality, I'll take it as a win! So glad to hear this helped you out. We have some plans to do some content on Svelte Kit, but that basics of what are in this video are about the same for all of the meta-frameworks. Thanks again for watching and the kind words - JE

  • @dontbothermeidiot
    @dontbothermeidiot Рік тому +1

    This is the best, easy to understand. Thank you so much for your effort.

  • @pick_pick_pick
    @pick_pick_pick 11 місяців тому

    amazing easy tutorial, i used it for my custom post type and everything works great, specially for the HTML generation for SEO

  • @traveltheworldandcode
    @traveltheworldandcode Рік тому

    this is exactly what I haven been looking for. great tutorial

  • @chrismartinez5711
    @chrismartinez5711 2 роки тому +1

    Awesome tutorial. Straight to the point!

    • @WPEngineBuilders
      @WPEngineBuilders  2 роки тому +1

      Awesome! Thanks for the kind words and thanks for watching!

  • @andiskene7346
    @andiskene7346 2 місяці тому

    Thank you for this! I was completely lost about how to get the data from point A to point B.

  • @SiBtoday
    @SiBtoday 2 роки тому +1

    Amazing Tutorial, thank you very much!

  • @qavinizamani5889
    @qavinizamani5889 2 роки тому +1

    There are not enough words to appreciate your efforts! Really amazing 💯

    • @WPEngineBuilders
      @WPEngineBuilders  2 роки тому +1

      Aww shucks, thanks for the kind words, and thanks for watching - Jeff

  • @donjudejoseph6000
    @donjudejoseph6000 Рік тому

    Amazing one. Thank you for this

  • @devio7427
    @devio7427 7 місяців тому

    Thank you

  • @SkyrimBeast
    @SkyrimBeast 7 місяців тому

    Jeff, thank you so much for this video. The instructions provided worked perfectly in my app. Much ❤

  • @victorfrancis1378
    @victorfrancis1378 2 роки тому

    Thank you so much. Can I add categories using the gql.

  • @shravyahegde5343
    @shravyahegde5343 4 місяці тому

    I have tried this example exactly the same. but on opening the site locally it's not showing the posts page. instead, home page contents includes
    "A commitment to innovation and sustainability". Am I missed anything to load posts on the front page?

  • @thedigitalceo
    @thedigitalceo 2 роки тому +1

    Is there any benefit
    to doing this with graphql instead of simply pulling data from the Wordpress json endpoints?

    • @WPEngineBuilders
      @WPEngineBuilders  2 роки тому

      Hey! Yes, there are a number of reasons why you may want to use WPGraphQL instead of the WordPress REST API. Check out this great video for a detailed comparison between those two options: ua-cam.com/video/o-7-_oLq23c/v-deo.html

  • @alexmaldonado7209
    @alexmaldonado7209 2 роки тому

    Great video, thanks! Also instead of copying and pasting when changing directories in the terminal you can use the autocomplete feature. Type cd and then type the first letter or first few letters of the directory you want to cd into and press tab to autocomplete!

  • @zacharystout8573
    @zacharystout8573 Рік тому +1

    Can this work with an already existing WordPress site? Would I be able to convert a current WP site to headless?

    • @WPEngineBuilders
      @WPEngineBuilders  Рік тому +1

      Yeah, that is what a lot of folks do is migrate a current site to headless. Any specific questions you have about the how/why?

    • @zacharystout8573
      @zacharystout8573 Рік тому

      @@WPEngineBuilders Hey thanks for getting back to me! Yeah, I was just wondering specifically how to perform a migration vs. a brand new project.

  • @offthewallchess
    @offthewallchess Рік тому

    Thank you so much for this!!!!

  • @allure-md
    @allure-md 11 місяців тому

    Nice work!

  • @JustinUrich
    @JustinUrich 2 роки тому +2

    Extremely thorough tutorial, Jeff. I appreciated your teaching style of explaining in clear detail exactly what each line/section of your code was doing. Only negative feedback I have is the intro and outro music 😂 Question: For your posts detail page - are you statically generating for all known URLs? I was confused by the usage of posts = [] and what exactly it meant in that context.

    • @WPEngineBuilders
      @WPEngineBuilders  2 роки тому

      Thanks for your kind words and feedback about our intro beats. You can statically generate all pages at build time if you pass all of the possible paths into that array, or even generate some by only including your most common paths. When we leave the array empty, we build every path on the first request and then use the static page for every subsequent request, so the first user to hit the page has a slightly longer request time. The getStaticPaths function is pretty flexible, so it doesn't have to be all or nothing. Thanks for watching, and happy to answer any other follow-ups - Jeff

  • @abenjamin13
    @abenjamin13 2 роки тому

    I greatly appreciate the setup and I’m going try “local” instead of WAMP. Looks better thank you 🙏

  • @ASEVEN_STAR
    @ASEVEN_STAR 2 роки тому +1

    oke, thank you very much.. have a nice bro

  • @enricosimonetti5050
    @enricosimonetti5050 Рік тому

    Great course!
    One thing that I couldn't grasp yet is to understand if the WordPress instance could be brought up and down during static site generation only, as an "admin ui" or it needs to stay alive. And if WordPress can be off most of the time, where would the occasionally fetched data stored?
    The use case im thinking of is a user brings up WordPress, adds or edits posts, a github sction script runs and generates the static website, which will then be served statically until the next edit.
    Thank you foe your hints!

    • @WPEngineBuilders
      @WPEngineBuilders  Рік тому

      Thanks for the kind words. It kind of depends on how you build your site. If you statically generate everything at build time, then yeah you could shut off the WP site and serve just static files. In practice, we don't see a lot of people do that though - JE

  • @AlexandruRada
    @AlexandruRada 2 роки тому

    curios what you've used to create the video and add the webcam recording as well.

    • @WPEngineBuilders
      @WPEngineBuilders  2 роки тому +1

      We all use an app called screenflow to record/edit videos

  • @Light-3121
    @Light-3121 Рік тому

    why i dont run npm run dev after create file .env.local
    my terminal say EPERM: operation not permitted, open 'C:\Users\Asus\crash-course-headless-wp-next-wpgraphql\.next\trace'

  • @mjohnson82
    @mjohnson82 Рік тому

    Great tutorial! Question... what would be the next steps from here, like... displaying images, loading pages with different layouts, etc?

    • @WPEngineBuilders
      @WPEngineBuilders  Рік тому +1

      I would recommend checking out Faust.js actually. It's built on top of Next.js, but offers a bunch of functionality out-of-the-box: faustjs.org/

    • @mjohnson82
      @mjohnson82 Рік тому

      Cool, thank you!@@WPEngineBuilders

  • @dryujin1004
    @dryujin1004 Рік тому

    Thanks I learned alot from this tutorial. really appreciate it.
    I have few questions.
    one is, is it possible to create new data in next js, and then that data added into wordpress.
    last question is about 6:42 in your video,
    crashcoursesite.wordpress.xml file was imported to wordpress. what was the purpose of the import file?

    • @WPEngineBuilders
      @WPEngineBuilders  Рік тому

      Hi, thanks for watching. Yeah, you could do that if you wanted but it would require authentication depending on the type of data. To create a post or page you would need to authenticate as a WP user, but a comment you could create without auth. That XML file was the basic WordPress export file of my content. Thanks for watching - JE

  • @tsxpneo
    @tsxpneo 2 роки тому

    Hi! Thanks for this tutorial, very helpful - one thing I'm still wondering about are dynamic routes with respect to hierarchically nested content structures. Most WP installations I've worked on usually have custom post types that are potentially hierarchical, but the same is true for subcategories or pages. Most next/react routing tutorials apparently assume there's only one dynamic slug element in a url. And that's not necessarily always the case - Eg, assume there's a page "Level-1" with two children "Level -2-a" and "Level-2-b". Here we could potentially still hardcode the "Level-1" part of the URI. But assume now, that an editor creates a third child page "Level-2-c" and then a child page thereof, "Level-3-a", which would result in a URI with two (and potentially more dynamic/slug elements): //level-1/{level-2-c}/{level-3-a}. Will this params from URI approach also work for routing in that case? If not, how could this be done? Could this be done? Thanks!

    • @WPEngineBuilders
      @WPEngineBuilders  2 роки тому +1

      Hi, Thanks for the awesome question! You're right that the routing here is pretty simplistic. One more advanced pattern I've seen is using a catch all route in Next.js and the nodeByUri query, I think this pattern better respects WordPress routing: www.wpgraphql.com/2021/12/23/query-any-page-by-its-path-using-wpgraphql

    • @tsxpneo
      @tsxpneo 2 роки тому +1

      @@WPEngineBuilders and again thanks a lot for that most helpful reply =)

  • @joshbarros1995
    @joshbarros1995 2 роки тому

    Nice explanation! Thank you very much!!
    What if I try to add a non-existent postname on the url?
    Will the application break or should it throw a 404 page?

  • @JoseRomero-nc3gu
    @JoseRomero-nc3gu 2 роки тому

    Nice stuff. Could you explain on a video how to deliver (upload) the app on nextjs. I saw Vercel as an option but maybe there is an easy way. Thanks.

  • @tomm3416
    @tomm3416 2 роки тому

    Great tutorial. The only thing I don’t seem to understand is how to automatically update the website. Now when I made a change I’ll have to save a file before its get updated on the website. Can I make this more user friendly? Maybe some sort of button in de backend where you can push your changes to the live website.

    • @WPEngineBuilders
      @WPEngineBuilders  2 роки тому +1

      Hi Tom, thanks for the question. This tutorial does not dive into the details of how these sites get deployed, but there are a few ways we typically handle things. 1) if you're making changes to the Next codebase, pushing those changes to GitHub would automatically rebuild that part of your site on most JS hosting platforms 2) if you're talking about the content in WordPress being updated automatically, that can happen as well in a variety of ways depending on how you've instructed Next to render your site. If it's ssr, you'll always get fresh data. If SSG, you can trigger a rebuild using a webhook on most platforms, and Next also has ISR, which is kind of an in-between mode where it is static but revalidated at an interval you define, and that is what we typically recommend. Let me know if you need more details on any of this - JE

  • @nx3057
    @nx3057 Рік тому

    I wonder if there is a way to hide all post on wordpress but still be able to query and show posts on NextJS, any thoughts? 🤔

    • @WPEngineBuilders
      @WPEngineBuilders  Рік тому

      Our FaustWP plugin does a lot of redirecting of public WP URLs to the frontend site, if that is what you mean. Faust.js is built on Next.js so it should be relatively easy to get started with: faustjs.org/docs/faustwp/settings

  • @afxcrush41
    @afxcrush41 2 роки тому

    thank you dude!

  • @TheNamesJT
    @TheNamesJT Рік тому

    Can you make a tutorial on how to use remix instead of next.js?

    • @WPEngineBuilders
      @WPEngineBuilders  Рік тому +1

      Boom, here you go: ua-cam.com/video/4jT7iKdqoW4/v-deo.html

    • @WPEngineBuilders
      @WPEngineBuilders  Рік тому

      Thanks for watching - JE

    • @TheNamesJT
      @TheNamesJT Рік тому

      @@WPEngineBuilders I was hoping for remix, wordpres headless and vercel free hosting tutorial. I don't have money for WPEngine as the hosting provider.

  • @magimaartdeveloper7465
    @magimaartdeveloper7465 2 роки тому

    Great tut bro, i have a question. Is possible to post data from Nextjs App back to wordpress(mySql database).
    For example you have a form data of say a user {name:"John", age:12}, and one wants to post this data via graphql to wordpress, is this possible??
    Or its only through wordpress dashboard that one can make a post request.

    • @WPEngineBuilders
      @WPEngineBuilders  2 роки тому

      Sorry we missed this comment, but yes that is possible through WPGraphQL mutations. But many of the popular form plugins also have APIs and WPGraphQL extensions, so it could be worth checking that out so that you can still use Gravity Forms or whatever plugin you use to build the form

  • @wilonweb
    @wilonweb Рік тому

    It's works with nextjs 13 ?

    • @WPEngineBuilders
      @WPEngineBuilders  Рік тому

      We're working on that piece of content using the app directory

  • @rajtechnology9964
    @rajtechnology9964 2 роки тому

    Hi, I am getting the error: Module not found: Error: Only absolute URLs are supported

    • @ecomproz
      @ecomproz Рік тому

      same

    • @walkonmars
      @walkonmars Рік тому

      Me too. did you manage to resolve this?

    • @rajtechnology9964
      @rajtechnology9964 Рік тому

      @@walkonmars no 😂, I drop the idea and move to react app

  • @biLLie_wiLLie
    @biLLie_wiLLie 2 роки тому

    thank you for this! Great video. It works. Question - I created an advanced custom field (events) and I don't see it in query composer. What should I do to see it. I want to publish not only posts. And second one - how to make contact form that sends emails from users to my email?

    • @WPEngineBuilders
      @WPEngineBuilders  2 роки тому +1

      You'll need to install this plugin to make ACF and WPGraphQL work together: www.wpgraphql.com/acf/

  • @Shawn-Mosher
    @Shawn-Mosher 2 роки тому

    I feel the only gotcha is dealing with wp-blocks editor content. Pulling in default styling from wp-blocks css and overwriting it to fit your needs or writing it from scratch is not ideal. I like the idea of replacing the content with a custom component using the wpgraphql content. Not currently implemented. The Gutenberg wpgraphql isn’t ideal either due to the deep nesting involved.

    • @WPEngineBuilders
      @WPEngineBuilders  2 роки тому +1

      Thanks for the comments, Shawn. We are in agreement that what you describe is still a common sticking point for building headless sites/apps. I know a lot of people in the community are paying attention to this problem, so hopefully this continues to improve.

  • @DanteMishima
    @DanteMishima 2 роки тому

    What is this thing you clicked create new site on?

  • @ychinamale
    @ychinamale 2 роки тому

    Amazing content! 🎉
    Could you reduce the volume of intro and outro music by 90%?
    I don't think it adds anything to the video. It only makes it very difficult to hear what you're saying at those points.

    • @WPEngineBuilders
      @WPEngineBuilders  2 роки тому

      Thanks for the feedback, I learned from this mistake in subsequent videos

  • @arielguzman1981
    @arielguzman1981 Рік тому

    For some reason my process.env.NEXT_PUBLIC_WORDPRESS_API_URL shows up as undefined. My .env.local file is in the right place, unsure why this is happening

    • @arielguzman1981
      @arielguzman1981 Рік тому

      =The actual error is "error - Error: Failed to parse URL from undefined/graphql"

    • @WPEngineBuilders
      @WPEngineBuilders  Рік тому

      @@arielguzman1981 I would make sure you stop and restart your server as a first step. If you make changes to the .env file, you need to reload it so the new values are there