JavaScript redirects are one of the methods available to webmasters in communicating to both users and search engines that the requested URL is unavailable, permanently or temporarily. The URL you will be served should be seen as the alternative or new always. Typically, best practice echoes that you should use 301s, 302s, or 307s on the server side. However, let’s take a look at headless website architectures, which are becoming increasingly popular. We note that not all Headless builds allow for server-side redirects and rely on client-side implementation – these being JavaScript redirects. Although some headless CMS platforms have provisions to configure redirects either at a server or application level, one of the benefits of moving to a headless architecture is that you no longer run a monolith but a microservice model.
Because of this, developers will look to reduce dependencies and create flexibility in the stack. Managing redirects in the front-end (eg, Vue.JS) means you can Special Database change CMS with one less consideration. That’s where we, as SEO pros, need to outline and establish URL redirect capabilities when a client is looking to migrate to a headless architecture or any other form of JAMstack tech stack. In terms of how JavaScript redirects work, they are typically implemented through the window.location.replace function and work well for users. But how well search engines interpret them is open to debate. In Google Search Central documentation, the search engine warns that you should.
Only use JavaScript redirects if you can’t do server side or meta refresh redirects. And with their inclusion, it gives the impression that they work for Google and from an SEO perspective (anecdotally speaking, this is definitely the interpretation that many developers had). But in contrast, as recently as 2020, Google’s Gary Illyes publicly stated that JavaScript redirects “are probably not a good idea.” js redirects are probably not a good idea. — July 8, 2020 This was in direct response to a thread about and redirects. Nevertheless, it raises questions about why they might not be a good idea, potentially reaffirming that Google’s documentation warns against using them as a priority solution.