Prismic Client 3.0.0-alpha

🤔 Something feels wrong with the client kit? Let us know in the ongoing Vue 3 Kit RFC!

The Client kit takes care of injecting methods and properties to query the Prismic API inside your Vue.js application. It's built on top of the Prismic Client package.

Configuration

No configuration is available so far for the Client kit. It inherits directly from top-level options provided to the plugin.

interface ClientOptions {}

interface PrismicPluginOptions {
    /* ... */
    client?: ClientOptions;
}
const prismic = createPrismic({
    /* ... */
    client: {},
});
const prismic = createPrismic({
    /* ... */
    client: false,
});

Properties

client

It's an instance of @prismicio/client already configured with your endpoint and API options, use it to fetch content from Prismic.

src/views/index.vue
export default {
  async created() {
    const document = await this.$prismic.client.getByUID("page", "home");
  }
  /* ... */
};
src/views/index.vue
import { usePrismic } from "@prismicio/vue";

export default {
  async setup() {
    const prismic = usePrismic();

    const document = await prismic.client.getByUID("page", "home");
  }
  /* ... */
};

Learn more about querying the API on Prismic documentation.

Predicates

An object that contains all Prismic predicates exposed by @prismicio/client.

src/views/index.vue
export default {
  async created() {
    const document = await this.$prismic.client.query(
      this.$prismic.Predicates.at('my.page.uid', "home")
    );
  }
  /* ... */
};
src/views/index.vue
import { usePrismic } from "@prismicio/vue";

export default {
  async setup() {
    const prismic = usePrismic();

    const document = await prismic.client.query(
      prismic.Predicates.at('my.page.uid', "home")
    );
  }
  /* ... */
};

See the complete predicate reference on Prismic documentation.

previewCookie

The name of the preview cookie Prismic is using.

Edit this page on GitHub Updated at Thu, Aug 12, 2021