Use Faust.js in existing Next.js installation #1814
-
Hi! I'm eager to start using Faust.js, but I can't find any documentation regarding using my existing Next.js installation with Faust.js. Is that because that's not possible and I should create a new project based on Faust.js and continue from there? Or can I just install certain packages, create certain directories, etc. to get started with my existing installation? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey @EnablingLogic It would be possible to start using Faust.js on an existing Next.js installation.
"@apollo/client": "^3.6.6",
// faust.config.js
import { setConfig } from '@faustwp/core';
import templates from './wp-templates';
import possibleTypes from './possibleTypes.json';
/**
* @type {import('@faustwp/core').FaustConfig}
**/
export default setConfig({
templates,
plugins: [],
experimentalToolbar: true,
possibleTypes,
});
//package.json "scripts": {
"dev": "faust dev",
"build": "faust build",
"generate": "faust generatePossibleTypes",
"stylesheet": "faust generateGlobalStylesheet",
"start": "faust start"
},
import '../faust.config';
import React from 'react';
import { useRouter } from 'next/router';
import { FaustProvider } from '@faustwp/core';
import '@faustwp/core/dist/css/toolbar.css';
export default function MyApp({ Component, pageProps }) {
const router = useRouter();
return (
<FaustProvider pageProps={pageProps}>
<Component {...pageProps} key={router.asPath} />
</FaustProvider>
);
}
// pages/api/faust/[[...route]].js import '../../../faust.config';
import { apiRouter } from '@faustwp/core';
export default apiRouter; Now if you are using the WordPress Template system you need to add the [...wordPressNode].js component And add your WordPress Templates: https://github.com/wpengine/faustjs/tree/canary/examples/next/faustwp-getting-started/wp-templates |
Beta Was this translation helpful? Give feedback.
Hey @EnablingLogic It would be possible to start using Faust.js on an existing Next.js installation.
"@apollo/client": "^3.6.6",
"@faustwp/cli": "^2.0.0",
"@faustwp/core": "^2.1.2",
"graphql": "^16.6.0",
//package.json