Giter Club home page Giter Club logo

Comments (7)

MightySCollins avatar MightySCollins commented on May 22, 2024 2

Thanks @jamespohalloran for looking into this. I think I have slightly more understanding now. Your API does not have auth for the server side build so me switching to the createClient as opposed to createLocalClient causes it to break as it was trying to get a token which uses localStorage on the client side. Instead you run a local server to read the content locally on build.

It might be an idea to check if you are in a browser environment before the call to make it clearer to new people.

from tina-cloud-starter.

jamespohalloran avatar jamespohalloran commented on May 22, 2024

Hey @MightySCollins, I can speak to part of this!

Also I notice the usage of createLocalClient for example at https://github.com/tinacms/tina-cloud-starter/blob/main/pages/posts/%5Bfilename%5D.tsx#L41 and https://github.com/tinacms/tina-cloud-starter/blob/main/pages/index.tsx#L45 which ignores the NEXT_PUBLIC_USE_LOCAL_CLIENT option. Should this not just be createClient()?

The reason that the local client is always used within getStaticProps, is so that we can always use local files to statically build your production site.
The Tina Cloud server currently requires a logged-in user session, so it is only used in edit-mode (when your editors are logged in).

from tina-cloud-starter.

jamespohalloran avatar jamespohalloran commented on May 22, 2024

Was the ReferenceError: localStorage is not defined popping up when using the Tina Cloud Client within getStaticProps ?

I will add that having a long-lived token for accessing the Tina Cloud API (that could be used at build-time) is something we've discussed, but aren't ready for yet.

from tina-cloud-starter.

jamespohalloran avatar jamespohalloran commented on May 22, 2024

It might be an idea to check if you are in a browser environment before the call to make it clearer to new people.

Yep! that's a great idea. I think this might be a common thing that users may run into when using the client.

from tina-cloud-starter.

MightySCollins avatar MightySCollins commented on May 22, 2024

@jamespohalloran Just had a thought... Does this mean that TinaCMS wont work with GCP if you use revalidate? We have pages which pull from another API but when they revalidate hourly the tina graphql server is not running at 4001 as it was only done on the build step.

from tina-cloud-starter.

jamespohalloran avatar jamespohalloran commented on May 22, 2024

I haven't used GCP, so let me know if I'm misunderstanding your use case. It sounds like the pages that you're referring to are using SSR, to pull content from another API, and then are cached with GCP?

Right now, any pages that use Tina Cloud for their content need to be built statically when the local graphql server is still available (at build-time). If the pages being rebuilt with revalidate are separate from your pages talking to Tina Cloud, you could mix/match static pages & SSR pages.

Curious to hear more about your use case though, would the static-only restriction would be a dealbreaker for you?

from tina-cloud-starter.

MightySCollins avatar MightySCollins commented on May 22, 2024

Sorry my phone tried to help. I meant to type getStaticProps GSP. Lets say I have a product page which contains some static information from Tina Cloud but I also want to pull the latest product price I would add in revalidate so Next.JS will invalidate the props over time. I also might have the list of products are really long, dynamic and constantly changing so I would not want to use getStaticPaths but have Next.JS fire the requests when a user requests that product.

We even have use cases on sections like the homepage where we display popular products again with revalidate. Unfortunately Next.JS does not let you mix and match on the same page. Now I could run a local build server firewalled and have the app call that but its quite a bit of overhead and I assume the cli tool is not really optimised for production.

from tina-cloud-starter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.