Image Gallery in NextJs Using SwiperJs

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

КОМЕНТАРІ • 66

  • @emmanueljulius1827
    @emmanueljulius1827 10 місяців тому +5

    Awesome implementation, the typescrpt version would be very much appreciated

  • @AaronTMac
    @AaronTMac Рік тому +2

    this channel is going to hit 100k+ subs so fast

  • @anversadutt
    @anversadutt Рік тому +2

    as always gr8 content and useful. surely will use in my next project, thx bro

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

      Great to hear that! I appreciate it.

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

    Thank you for the video. Would have been great to see this used in a server side component while ensuring performance.

    • @hamedbahram
      @hamedbahram  Рік тому +2

      Thanks! Can't use the SwiperJs on the server, it requires React hooks and browser APIs.

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

      Isn't it possible to pass a server component as a children prop to the SwiperSlide component? @@hamedbahram

  • @christiandavidnorenavalenc9944
    @christiandavidnorenavalenc9944 6 місяців тому +2

    Why didn't you tell us that Swiper React will be deprecated coming soon? I'm sorry that Swiper won't be supported for React anymore in the future. :(

    • @hamedbahram
      @hamedbahram  6 місяців тому

      I still use Swiper in my React projects, even if it gets discontinued meaning that they won't release new updates, the previous versions will continue to work. If you're looking for an alternative look at this one → ua-cam.com/video/pfZx8y74KE4/v-deo.html

    • @christiandavidnorenavalenc9944
      @christiandavidnorenavalenc9944 6 місяців тому +1

      @@hamedbahram I agree with you. Our projects still will be working with previous versions, although we'd miss the benefits of the updates to new versions. Thanks for your contribution. 😁👍
      Pd: Swiper won't be supported for Vuejs in the future anymore.

  • @fakhrulislamfuad8072
    @fakhrulislamfuad8072 Рік тому +2

    Bro, I need to implement geolocation inside of my nextjs 13 app. Can you make a video on how to use geolocation in the server side of nextjs 13? TYSM😃

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

      Sure, I'll have that in mind. From a high level, accessing user's geolocation requires the `navigator` object in the browser, so you'd need to use a client component for that.

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

      ​@@hamedbahramthank you bro..

  • @weehongayden90
    @weehongayden90 3 місяці тому

    I’m curious to know how do you setup the import order. It’s so neat and comfortable to the eyes.

  • @levipadre
    @levipadre 11 місяців тому +2

    Hi, thanks for the video. Do you know how to overwrite the navigation style. I use SCSS module on other components, but it doesn't work on this slider for some reason.

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

      It may be specificity issue. You can target the navigation button by `.swiper-button-prev` and `.swiper-button-next` css classes. Try passing the `!important` flag to override the swiper styling.

  • @JM1675
    @JM1675 5 місяців тому +1

    Thanks for the tutorial! Do you know how I can implement swiper gallery in a specific part of my site in Next JS if I have different components and already a page.tsx file in my app folder?

    • @hamedbahram
      @hamedbahram  5 місяців тому

      Of course you can, what is the problem you're facing?

  • @aldairandre
    @aldairandre Рік тому +2

    This would be a better video if your project was using typescript, it's almost impossible to work with swiper and typescript

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

      Hmm 🤔 haven't had that experience!

  • @ak.687
    @ak.687 11 місяців тому +1

    I am using NextJs 13 and swiper v10.3.1 but it's giving getStaticPaths is not a function error. How to resolve this?

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

      Are you using the App router?

  • @codedusting
    @codedusting 10 місяців тому +1

    How to add multiple sliders in one page where keyboard pressing doesn't change other slider's slides.

    • @hamedbahram
      @hamedbahram  10 місяців тому

      You can create different instances using the `Swiper` component.

    • @codedusting
      @codedusting 10 місяців тому +1

      @@hamedbahram How? I have multiple swiper components in a page but still the same result 😕. Thanks for replying though.

    • @hamedbahram
      @hamedbahram  10 місяців тому

      @@codedusting I'm not sure if I understand the problem here. If you have two `` components in a page, they would work independent of one another.

    • @codedusting
      @codedusting 10 місяців тому

      @@hamedbahram Yes, thought the same. But when I press the keyboard right or left arrow to slide up the slides, all slides in the page move. And the docs are not helpful either.

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

    Hello.
    How do you solve the problem in NextJs, when not one slide is displayed but 3 at once. The problem is that at first 1 slide is shown and then the other 2 are loaded and it looks like a bug?

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

      You can pass `priority` prop on your `Image` component for the first three images to avoid lazy loading.

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

      @@hamedbahram I don't have any pictures. The problem here is that the container is being loaded. This is the only way I have solved it:
      import dynamic from 'next/dynamic'
      const myComponent = dynamic(() => import('@/components/myComponent'), {
      ssr: false
      })
      export default function Example() {
      return (

      )
      }

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

      @@yagelProject I see, well are you using this inside a server component? Cause the swiper sdk requires react hooks and browser APIs to work correctly.

  • @jesushurtado1560
    @jesushurtado1560 7 місяців тому +1

    Thanks. What if I need to fetch data from the server? I need to use a method that call a graphql query and that will be the cards on the swiper

    • @hamedbahram
      @hamedbahram  7 місяців тому +1

      You can use the `swiper` APIs to control the slides.

  • @saikrishnamuntha62
    @saikrishnamuntha62 6 місяців тому +1

    which one is the best swiper or emblac react and UI need should be effective

  • @Beast80K
    @Beast80K 11 місяців тому +1

    Respected Sir,
    I would like to ask you if it's possible to make a marquee like continuous sliding in Swiper JS ?

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

      Thanks! I'm not sure what a marquee like sliding is but you can see their example implementations here → swiperjs.com/demos

  • @kiuri.
    @kiuri. 11 місяців тому +1

    Hi! Thank you for the video! How can you use the Image component without explicitly setting the width and the height?

    • @hamedbahram
      @hamedbahram  11 місяців тому +1

      If you import images statically into the component using it (as I'm doing here) you won't need to set explicit dimensions on the `image` component.

    • @kiuri.
      @kiuri. 11 місяців тому +1

      @@hamedbahram got it! Didn't know about that. Thank you!

    • @hamedbahram
      @hamedbahram  11 місяців тому +1

      @@kiuri. Anytime.

  • @floodx1668
    @floodx1668 10 місяців тому +1

    you are the best

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

    what font are you using please, it's cool

  • @alinasrabadi749
    @alinasrabadi749 9 місяців тому +1

    How about 'use server' component?

    • @hamedbahram
      @hamedbahram  9 місяців тому

      The swiper component requires a client component to work.

  • @joaomaia9140
    @joaomaia9140 10 місяців тому +1

    Tried with .tsx and doesnt work why is that? thanks

    • @hamedbahram
      @hamedbahram  10 місяців тому

      It's probably SwiperJs types.

  • @farzanfakourian443
    @farzanfakourian443 8 місяців тому +1

    kheily khub bood mersi

  • @magicmanik7
    @magicmanik7 21 день тому

    I need to make the swiper images seo friendly. How can I render swiper images on sever side?

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

    Great example! I think swiper react comps are going to be replaced by Swiper Element in future versions.

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

      I've seen that note on the docs. React doesn't support web components yet, and until they do, the SDK is the most declarative way to use Swiper in React.

  • @mohsenmohammadirahnama
    @mohsenmohammadirahnama 3 місяці тому

    Can you help me how to use Swiper in ssr page in Nextjs14?

    • @hamedbahram
      @hamedbahram  3 місяці тому

      Swiper requires browser APIs and can only be used in client components.

  • @mehdiraized
    @mehdiraized 9 місяців тому +1

    i think embla-carousel better than swiper please check this package

    • @hamedbahram
      @hamedbahram  9 місяців тому

      Nice package I liked it. Thanks for the suggestion.

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

      Check this out → ua-cam.com/video/pfZx8y74KE4/v-deo.html

  • @enza9189
    @enza9189 9 місяців тому +1

    Like!