Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted over 3 years ago

Next.js Site with Sanity.io (Headless CMS), styled with SCSS

James F. Ciskanik•200
@JamesTheLessFC
A solution to the Audiophile e-commerce website challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


So this project took me about 2.5 weeks to complete, spending several hours most days. For someone who is looking to get into the web development field, is that timeframe reasonable/acceptable?

Another question I had is in regards to the images featured on the site. Basically what I'm doing is loading three versions of each image (mobile, tablet, desktop) into the page and then only showing the correct image, by using "display: none" on the others (I'm doing this using media queries.) Am I correct in assuming that the browser is loading each of the images, which in effect slows the load time? And if so, is there a better way to implement this? Maybe using javascript to find out the screen-width and loading the correct image based on that?

I thought the biggest challenge with this project was figuring out how to set up a headless CMS and load data from there, something I've never tried before. I went with Sanity.io, which offers a lot of helpful documentation and allowed me to actually host the CMS on the site itself (at <live-domain>/admin). I got it to work fine, but I'm curious about other headless CMS examples which might work better?

Finally, I'm using React's context hook to manage the state of my site's shopping cart/checkout process. I was tempted to use Redux but it felt unnecessary. Was this the right decision? There seems to be quite a lot of debate on this topic.

This was a fun project and I learned a lot from it. Any other feedback is welcome and appreciated! Thanks.

Code
Loading...

Please log in to post a comment

Log in with GitHub

Community feedback

  • Jay•695
    @Junjiequan
    Posted over 3 years ago

    I have used redux, redux-tookilt and redux-thunk for my previous projects.

    For me, redux only get complicate when the architecture is not planned thoroughly. In other words, when you are going to use redux it is better to have clear understanding regards to how many state changing activities is need to be included.

    The initial step for setting up redux logic is the most difficult & complicated part for me not the code itself make the process complicate. Once the initial setup is done, it makes the whole process much more effective and easy to maintain with useSelector and useDispatch hook, you can always add additional reducers & actions effortlessly.

    Lastly, I strongly recommend to tryout redux-thunk. It is a middleware that allows to return a function. Its really usefull when your project is required to interact with server-side, e.g., you could use it to GET data from API and use returned data to dispatch actions, example code below:

    export const fetchPosts = () => axios.get(http://localhost:5000/posts);
    
    export const fetchAllPosts = async (dispatch: AppDispatch) => {
      try {
        const { data } = await fetchPosts();
        dispatch({ type: "FETCH_ALL", payload: data });
      } catch (err: any) {
        console.log(err.message);
      }
    };
    

    This is just my opinion, I wouldn't consider too much about time spend on a project when I am learning. The more time you spend usually means the more you considerate about the project. For me, it is harder to create good quality project with more time than creepy quality with less time, eye on details require a lot of patient and extra efforts.

    Hope this feedback helps.

    Marked as helpful
  • Shivam•520
    @shivjoshi1996
    Posted over 3 years ago

    Hey @JamesTheLessFC, great job on this.

    To respond to a couple of your points:

    1. I've been a Project Manager for a few years working in Software Eng teams and in my experience, I think for someone who is a Junior F/E, 2 and a half weeks is reasonable for this kind of site considering you were working on it part-time. Obviously, if you had a solid 8-hours a day you might've got this done faster, and as you're still learning, the efficiency of how fast you write your code will only increase going forward. So I think in terms of how fast you're getting things done, you're on the right track.

    2. I can't give you a solid answer on the images in terms of best practices (since I'm also learning Sanity & NextJS) but I know Sanity has some special helpers for images (https://www.sanity.io/docs/presenting-images), and there is also a plugin for Sanity + Next specifically. Hopefully that points you in the right direction.

    3. From my personal experience Sanity is pretty great (It's the one I've also used the most while developing since it's the most straight forward IMO). For the content, Sanity would work fine. In a real-life situation, you'll probably be asked to hook the shop up to something like Shopify which can handle things like invoices, order tracking, etc. So while you'll still be able to use Sanity for the content (e.g. page content, product descriptions, images) I assume the actual product management will be handled in another system. That's way beyond the scope of this project though so don't worry too much about that! Some other headless CMS' I've used in my real-life role is Prismic (https://prismic.io/) and Contentful (https://www.contentful.com/) but these are mostly for static sites and not for an eCommerce store. I think if you try a couple of them out, the rest should be somewhat similar.

    4. From what I've read, the React Context API can be used for most cases rather than Redux which has known to be needlessly complex. For a relatively small project like this, I think Context is perfect.

    Great job overall!

    Marked as helpful

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord
Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

How does the accessibility report work?

When a solution is submitted, we use axe-core to run an automated audit of your code.

This picks out common accessibility issues like not using semantic HTML and not having proper heading hierarchies, among others.

This automated audit is fairly surface level, so we encourage to you review the project and code in more detail with accessibility best practices in mind.

How does the CSS report work?

When a solution is submitted, we use stylelint to run an automated check on the CSS code.

We've added some of our own linting rules based on recommended best practices. These rules are prefixed with frontend-mentor/ which you'll see at the top of each issue in the report.

The report will audit 1st-party linked stylesheets, and styles within <style> tags.

How does the HTML validation report work?

When a solution is submitted, we use html-validate to run an automated check on the HTML code.

The report picks out common HTML issues such as not using headings within section elements and incorrect nesting of elements, among others.

Note that the report can pick up “invalid” attributes, which some frameworks automatically add to the HTML. These attributes are crucial for how the frameworks function, although they’re technically not valid HTML. As such, some projects can show up with many HTML validation errors, which are benign and are a necessary part of the framework.

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub