How to Get Started with Sanity and Angular

9 replies
Last updated: Apr 12, 2021
Hello Sanity peeps! I see lots of starter projects for Sanity in use with NextJS, Vue, React, etc but not Angular. Is this because it’s not very compatible, or because it’s trivial to connect Angular to the Sanity API with a simple HTTPClient and send it a query string and therefore not worth an entire tutorial? I’d love to see a Stackblitz of Sanity with Angular!
Apr 11, 2021, 6:04 PM
Hi! Yes, it's like you said.But for handling portable text, it's nice to have already made component for your library. I'm sure there's one for Angular.
I also remember seeing this course in the twitter feed not long time ago:

https://explorers.netlify.com/learn/angular-dynamic-data-with-sanity-io
Apr 11, 2021, 6:58 PM
Great! I’ll check it out. Yeah the articles and tutorials I did find are for Angular but also include other technologies I don’t necessarily want to add right now like Netflify hooks, Angular Univeral server-side rendering, etc etc. I’m excited to connect to Sanity and get rolling! 🙂. But this will get me aware of those technologies and add them in the future when I understand the use case for them. Thank you for the link!
Apr 11, 2021, 7:09 PM
ah yes, sure, you don't need all of those, especially if you're building a SPA.I recommend using this client:
https://github.com/rexxars/picosanity
Apr 11, 2021, 7:39 PM
for rendering images, I use, like almost everybody here I guess, this library: https://www.sanity.io/docs/image-url Besides all the images manipulation capabilities, the main advantage for me is that I can just pass it an image asset and it will automatically resolve the URL of the image (otherwise you have to resolve the reference yourself inside the query).
Apr 11, 2021, 7:43 PM
and I highly recommend you make query using GROQ. I love that query language!
Apr 11, 2021, 7:45 PM
Yeah my brain really took to the GROQ syntax when I saw a video about it. And that image-url builder looks sweet. Thanks! It’s going to be a fun Sunday checking all this out!
Apr 11, 2021, 8:05 PM
Hey
user E
, why is Sanity always paired with Netlify functions and never just used as an endpoint with query strings at the end for queries? What am I missing?
Apr 12, 2021, 12:34 AM
It's strange that in this tutorial data are fetched through a Netlify Function. I guess Netlify just wanted to showcase this feature.I would only use serverless function if I'm working with a private dataset.

Also, you're building a SPA (no server rendering at build time), you also don't need to use Netlify build hooks.
Apr 12, 2021, 6:12 AM
Ok thank you for confirming. I thought it was to build complex queries that contain characters that would not be accepted as a query string like
?query=*[2]
but I could always convert those to html encoding like
%20
and all that
Apr 12, 2021, 1:11 PM

Sanity.io – build remarkable experiences at scale

Sanity is a customizable solution that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.