google-adsense
google-adsense copied to clipboard
Warning: `withDefaults()` is unnecessary when using `defineProps()` with destructuring
I am encountering a warning when using the @nuxtjs/google-adsense module in my Nuxt 3 project. The warning indicates that withDefaults() is unnecessary when defineProps() is used with destructuring. Here are the details:
Warning Message:
WARN [@vue/compiler-sfc] withDefaults() is unnecessary when using destructure with defineProps().
Reactive destructure will be disabled when using withDefaults().
Prefer using destructure default values, e.g., const { foo = 1 } = defineProps(...).
node_modules/@nuxtjs/google-adsense/dist/runtime/components/Adsbygoogle.vue
11 | hideUnfilled,
12 | includeQuery,
13 | } = withDefaults(defineProps<{
| ^^^^^^^^^^^^
14 | adClient?: string
15 | adSlot?: string | null
Environment:
Nuxt Version: ^3.14.1592 Module Version: "^3.0.0", Node Version: v20.15.0
+1
Any updates on this?
Have same issue. Any solution?
use @nuxt/scripts for Google Adseen or Google Anylists and more
use
@nuxt/scriptsfor Google Adseen or Google Anylists and more
Do you know how to applied Google adsense with @nuxt/scripts?
Do you know how to applied Google adsense with
@nuxt/scripts?
How to Apply Google AdSense with @nuxt/scripts
To integrate Google AdSense using @nuxt/scripts, follow these steps:
1. Install @nuxt/scripts
Add the @nuxt/scripts module to your Nuxt project by running:
npx nuxi@latest module add scripts
2. Configure nuxt.config.ts
In your nuxt.config.ts file, include the following configuration to enable Google AdSense:
export default defineNuxtConfig({
modules: ['@nuxt/scripts'],
scripts: {
registry: {
googleAdsense: {
client: 'ca-pub-xxxxxxxxxxxx', // Replace with your Google AdSense client ID
},
},
},
});
3. Add the Google AdSense Component
You can use the built-in ScriptGoogleAdsense component in your Vue templates:
<template>
<ScriptGoogleAdsense
data-ad-client="ca-pub-..." <!-- Replace with your Google AdSense client ID -->
data-ad-slot="..." <!-- Replace with your Ad Slot ID -->
/>
</template>
4. Handle Ad Blockers (Optional)
To gracefully handle users with ad blockers, leverage the #error slot to display a fallback message:
<template>
<ScriptGoogleAdsense
data-ad-client="ca-pub-..."
data-ad-slot="..."
>
<template #error>
<!-- Fallback message -->
Please support us by disabling your ad blocker.
</template>
</ScriptGoogleAdsense>
</template>
5. Verify Site Ownership (Optional)
For site ownership verification, you can use the useScriptGoogleAdsense composable and add a meta tag in your <head> section:
const adsense = useScriptGoogleAdsense({
client: 'ca-pub-<your-id>',
});
<meta name="google-adsense-account" content="ca-pub-<your-id>">
Required Tags
To ensure proper functionality, provide the following mandatory attributes:
data-ad-client: Your Google AdSense Client ID (e.g.,ca-pub-xxxxxxxxxxxx).data-ad-slot: Your Ad Slot ID.
Additional Resources
For more details, refer to the Official Documentation.
Yea but .. does nuxt/script implementation serve "test" ads ? I don't want to do the rountrip-to-production dance again , to test/adjust ads functionality. My needs are peculiar .. i do not want to toss ads at random.
@nexoscreator How come you deleted the PR addressing this issue?