create sitecore jss form with nextjs in headless xm cloud
madhusudan dayal
on
7/9/2023 7:55:26 AM
To Implement a Sitecore form in a JSS Next.js app i followed the sitecore offical link Sitecore jss form
I Created Component JssNextForm.tsx in jss App Component folder
Like below code:
import { Form } from '@sitecore-jss/sitecore-jss-react-forms';
import React from 'react';
import { NextRouter, withRouter } from 'next/router';
import {
sitecoreApiHost,
sitecoreApiKey
} from 'temp/config';
const JssNextForm = ({ fields, router }: { fields: any; router: NextRouter }) => {
return (
<>
router.push(url)}
/>
);
};
export default withRouter(JssNextForm);
I registered this component into Sitecore rendering as a json rendering item and selected Rendering Contents Resolvers as Sitecore Forms Resolver in layout service field and also data source location as Sitecore form.
I created simple form as Sitecore form, Name input field and a submit button.
I added Sitecore form rendering into page presentation details added form data source and publish.
i started the jss app in connected mode. by runing command jss start:connected
when i submit the form i am geting issue
Unexpected token '<', "<!DOCTYPE "... is not valid JSON
i followed the follwing articls to resolved this issue
1. Sitecore jss form submit action with nextjs
2. Sitecore Forms cannot be submitted if
we set the value of the serverSideRenderingEngineEditOnly app attribute to false
and also serverSideRenderingEngineEditOnly = false into Sitecore.JavaScriptServices.Apps.config in App_Config\Sitecore\JavaScriptServices.
Next
we patch the HeadlessSiteAccess processor after TransferRoutedRequest. name nextjssform.config
my console error after form submit
Kindly advice if you have faced and resolved the issues in headless xm cloud jss form with nextjs component, thanks in advance.
Check More Sitecore JSS or Sitecore Headless related articles:
Our Sitecore JSS Articles Click Here!
0 Comments on this post
Comments(0)||Login to Comments
- see more..
Categories
ALLAsp.Net (3)
Sitecore (11)
Issues Resolved (9)
Sitecore 9.3 (2)
International Business (1)
Innovations in Industries (3)
Supply Chain Management (1)
Industrial Engineering (14)
Sitecore 10 (4)
Sharepoint (1)
Azure (3)
Cloud Computing (1)
Online Courses (1)
Online Resources (2)
C# (1)
Blazor WebAssembly (2)
Sitecore form (1)
MS Sql Server (1)
Angular 11 (2)
Automobile Engineering (5)
Sitecore powershell (1)
Devops (2)
Microservice Architecture (1)
Sitecore Interview Questions (2)
Dotnet interview questions (1)
Sitecore useful links (1)
Privacy&Cookies (2)
Solr Search (2)
JavaScript (1)
sitecore xm cloud (2)