Skip to main content

Module: @evolv/nextjs

Classes

Interfaces

Functions

EvolvCoexistenceMode

EvolvCoexistenceMode(props, context?): null | ReactElement<any, any>

Component that activates coexistence mode in which the Evolv Asset Manager and the Evolv NextJS SDK can coexist.

Parameters

NameType
propsObject
context?any

Returns

null | ReactElement<any, any>


EvolvConsumer

EvolvConsumer(props, context?): null | ReactElement<any, any>

Parameters

NameType
propsObject
props.children(client: ClientAdapter) => Element
context?any

Returns

null | ReactElement<any, any>


EvolvProvider

EvolvProvider(props, context?): null | ReactElement<any, any>

Parameters

NameType
propsEvolvProviderProps
context?any

Returns

null | ReactElement<any, any>


debug

debug(namespace?): Debugger

Wrapper around Debug debug library.

Parameters

NameType
namespace?string

Returns

Debugger


getEvolvServerSideProps

getEvolvServerSideProps(options): PropsFactory<Result>

Server-side loader function that builds out the necessary data needed to hydrate page during rendering. The return value of this function will become the value of props that is passed to the page component.

Description

If a page does not need to export its own getServerSideProps() function, use the shorter form shown in the first example. If a page does need to export its own getServerSideProps() function, use the longer form inside the page's getServerSideProps() function to merge together page props and Evolv props.

Example

export const getServerSideProps = getEvolvServerSideProps(options);

Example

export function getServerSideProps(ctx) {
const pageProps = {};
const { props: evolvProps } = await getEvolvServerSideProps(options, ctx);

return {
props: {
...pageProps
...evolvProps
}
};
}

Parameters

NameType
optionsEvolvOptions

Returns

PropsFactory<Result>

getEvolvServerSideProps(options, ctx): Promise<Result>

Parameters

NameType
optionsEvolvOptions
ctxGetServerSidePropsContext<ParsedUrlQuery, PreviewData>

Returns

Promise<Result>


useConfig

useConfig<T>(key, initialState): T

Hook that returns the value of the given configuration key.

Type parameters

NameType
Tany

Parameters

NameTypeDescription
keystringName of configuration value
initialStateTValue to use before Evolv initializes or in the event of an error

Returns

T


useContextState

useContextState<T>(key): [T, Dispatch<T>]

Hook similar to React's useState() which returns a tuple containing a getter and setter.

Description

Hook sets a value on the Evolv context and will trigger a reaction that reevaluates variables based on the new context

Type parameters

NameType
Tany

Parameters

NameTypeDescription
keystringName of variable

Returns

[T, Dispatch<T>]


useEvolv

useEvolv(): ClientAdapter

Returns the client adapter, which contains values such as the Evolv client and hydrated state.

Returns

ClientAdapter


useIsKeyActive

useIsKeyActive(key): boolean

Hook that returns whether the given key is active or not.

Parameters

NameTypeDescription
keystringName of variable

Returns

boolean


useVariable

useVariable<T>(key, initialState): T

Hook that returns the variant allocated to the current user for the given variable.

Type parameters

NameType
Tany

Parameters

NameTypeDescription
keystringName of variable
initialStateTValue to use before Evolv initializes or in the event of an error

Returns

T