next-cloaking
v2.0.2
Published
Next-Cloaking is a NextJS package that allows to add "cloaking" functionality to every NextJS app. The term cloaking means rendering different content for the visitor of the website, depending on their User-Agent header. By doing this you can get better
Downloads
20
Readme
Add cloaking to NextJS
What's cloaking?
Cloaking in SEO refers to the practice of presenting different content or URLs to search engines and users. It is an attempt to deceive search engines and manipulate search rankings. It is used by many companies, but it is often not accepted by the search-engines and can result in penalties.
Warning! This can result in exponentially better results in SEO ranking but also in your site being removed from the algorithm or banned. I am not resposible for how you use this package.
How does this package work?
There's some ways to perform cloaking, but this package uses a custom _app.js
file. To be specific it's a custom wrapper you can easily add. More about this in the documentation. This wrapper takes the headers of every request and checks for crawler-headers. Depending on your config it redirects the "bot" to a other url. Like example.com/blog/seo
.
Installation.
First of all you should install the package:
npm install next-cloaking@latest
After it's installed you can switch to your app's _app.js
file. By default that's in the src/
directory.
You now need to add a Wrapper to it. Here's an example of a plain app using NextJS:
import '@/styles/globals.css'
import { CloakingWrapper } from "next-cloaking";
const config = {
seoRoute: "/seo-optimized"
}
export default function App({ Component, pageProps }) {
return <CloakingWrapper Component={Component} pageProps={pageProps} config={config} />
}
From now on every request get's redirected to /*path/seo-optimized
.
But you do not want to redirect every user to it, but only search engines. You can add some of the engines to the config directly. You can modify the config a bit, here's an example:
const config = {
seoRoute: "/seo-optimized",
engines: [
"Google"
]
}
This is just an example, adding it to the code is the first thing on the roadmap.
That's it and notes
You can now deploy your app to Vercel and enjoy the better ranking. Please note this can be banned by Google etc., and this package is just an explanation of it.