useStatamicRuntimeConfig

Gitlab
Get the Statamic runtime config object from the runtime config.
Added since: v1.0.0
Last changed:

Usage

The useStatamicRuntimeConfig composable is used to get the Statamic runtime config object from the runtime config.

You can optionally provide an event object to the composable to get the runtime config from that event. This is useful for server side requests.

Basic example

pages/blogs.vue
<script setup lang="ts">
const 
statamic
=
useStatamicRuntimeConfig
();
</script>

Advanced example

Provide the event object to the composable to get the runtime config from the event.

server/api/urls.get.ts
import type { 
EventHandlerRequest
,
H3Event
} from "h3";
export default
defineCachedEventHandler
(async (
event
:
H3Event
) => {
const
config
=
useStatamicRuntimeConfig
(
event
);
});

Type Definition

function 
useStatamicRuntimeConfig
(
_event
?:
H3Event
<
EventHandlerRequest
>):
Required
<
ModuleOptions
>

API Reference

Params

_event
H3Event<EventHandlerRequest>
The H3 event object containing request information.

If no event is provided, the runtime config will be taken from the global runtime config.

Return Value

Required<ModuleOptions>
The Statamic runtime config object.

The runtime config object is retrieved from the runtime config using the useRuntimeConfig composable.

Changelog

v1.0.0

on

#407d36db

-

feat: released initial version of nuxt-statamic